Class: Animal

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
CommonScopes, PublicActivity::Model
Defined in:
app/models/animal.rb

Constant Summary collapse

ANIMAL_IMAGE_OPTIONS =
{
  storage: :s3,
  s3_protocol: 'https',
  s3_credentials: {access_key_id: ENV['S3_KEY'], secret_access_key: ENV['S3_SECRET']},
  bucket: 'hospitium-static-v2',
  styles: { large: '530x530#', medium: '260x180#', thumb: '140x140#' },
  default_url: 'https://d4uktpxr9m70.cloudfront.net/images/no-animal-new-size-logo2.png',
  url: '/system/:class/:hash/:style/:filename',
  # :url  => "/system/:class_migration/:animalname_:orgname_:createdat/:style/:filename",
  hash_secret: ENV['SALTY']
}

Instance Method Summary collapse

Methods included from CommonScopes

included

Instance Method Details

#calculate_animal_ageObject


71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/models/animal.rb', line 71

def calculate_animal_age
  unless self.birthday.blank?
    age = "#{(Time.now.year - self.birthday.year).to_s} years"
    if age == '0 years'
      age = "#{(Time.now.month - self.birthday.month).to_s} months"
      if age == '0 months'
        age = "#{(Time.now.day - self.birthday.day).to_s} days"
      end
    end
  else
    age = ''
  end
  age
end

#formatted_adopted_dateObject


98
99
100
# File 'app/models/animal.rb', line 98

def formatted_adopted_date
  self.formatted_date('adopted_date')
end

#formatted_date(type) ⇒ Object


102
103
104
105
106
107
108
109
# File 'app/models/animal.rb', line 102

def formatted_date(type)
  unless self.send(type).blank?
    age = self.send(type).strftime('%a, %b %e %Y')
  else
    age = ''
  end
  age
end

#formatted_deceased_dateObject


86
87
88
# File 'app/models/animal.rb', line 86

def formatted_deceased_date
  self.formatted_date('deceased')
end

#formatted_intake_dateObject


90
91
92
# File 'app/models/animal.rb', line 90

def formatted_intake_date
  self.formatted_date('date_of_intake')
end

#formatted_well_dateObject


94
95
96
# File 'app/models/animal.rb', line 94

def formatted_well_date
  self.formatted_date('date_of_well_check')
end