Class: Totalizer::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/totalizer/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/totalizer/message.rb', line 3

def description
  @description
end

#durationObject

Returns the value of attribute duration.



3
4
5
# File 'lib/totalizer/message.rb', line 3

def duration
  @duration
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/totalizer/message.rb', line 3

def text
  @text
end

Instance Method Details

#percentage_string(value) ⇒ Object



13
14
15
# File 'lib/totalizer/message.rb', line 13

def percentage_string value
  "#{(value.to_f * 100).round(2).to_s.gsub(/.0$/, '')}%"
end

#period_stringObject



5
6
7
8
9
10
11
# File 'lib/totalizer/message.rb', line 5

def period_string
  if duration > 1
    "Last #{duration} #{'day'.pluralize(duration)}"
  else
    duration == 0 ? 'Today' : 'Yesterday'
  end
end