class Centaman::Attribute

Attributes

app_key[R]
centaman_key[R]
type[R]
value[RW]

Public Class Methods

new(args = {}) click to toggle source
# File lib/centaman/attribute.rb, line 7
def initialize(args = {})
  @centaman_key = args[:centaman_key]
  @app_key = args[:app_key]
  @type = args.fetch(:type, :string)
end

Public Instance Methods

age_group() click to toggle source
# File lib/centaman/attribute.rb, line 53
def age_group
  return 'adult' if value.downcase.include?('adult')
  return 'child' if value.downcase.include?('child')
  return 'youth' if value.downcase.include?('youth')
  return 'senior' if value.downcase.include?('senior')
  return 'adult'
end
boolean() click to toggle source
# File lib/centaman/attribute.rb, line 30
def boolean
  value
end
centaman_description() click to toggle source
# File lib/centaman/attribute.rb, line 38
def centaman_description
  value
end
datetime() click to toggle source
# File lib/centaman/attribute.rb, line 34
def datetime
  DateTime.parse(value)
end
display_age_group() click to toggle source
# File lib/centaman/attribute.rb, line 61
def display_age_group
  age_group.capitalize
end
display_time() click to toggle source
# File lib/centaman/attribute.rb, line 42
def display_time
  array = value.split(":")
  hour = array[0].try(:to_i)
  minute = array[1].try(:to_i)
  period = hour >= 12 ? 'pm' : 'am'
  hour = hour > 12 ? hour - 12 : hour
  return "#{hour}#{period}" if minute == 0
  "#{hour}:#{minute}#{period}"
  # return [array.first, array[1]].join(":")
end
float() click to toggle source
# File lib/centaman/attribute.rb, line 22
def float
  value
end
integer() click to toggle source
# File lib/centaman/attribute.rb, line 26
def integer
  value.try(:to_i)
end
parse_value() click to toggle source
# File lib/centaman/attribute.rb, line 13
def parse_value
  parsed_value = send(type)
  @value = parsed_value
end
string() click to toggle source
# File lib/centaman/attribute.rb, line 18
def string
  value
end