Class: IActionable::Objects::Progress

Inherits:
IActionableObject show all
Defined in:
lib/riaction/iactionable/objects/progress.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from IActionableObject

timestamp_regexp, timestamp_to_seconds

Constructor Details

#initialize(key_values = {}) ⇒ Progress

Returns a new instance of Progress.



12
13
14
15
16
17
# File 'lib/riaction/iactionable/objects/progress.rb', line 12

def initialize(key_values={})
  super(key_values)
  # convert the miliseconds within the date string to seconds (per ruby)
  # "/Date(1275706032317-0600)/" => "1275706032-0600"
  @condition_met_date = IActionableObject.timestamp_to_seconds(@condition_met_date) unless @condition_met_date.blank?
end

Instance Attribute Details

#completeObject (readonly)

Returns the value of attribute complete.



10
11
12
# File 'lib/riaction/iactionable/objects/progress.rb', line 10

def complete
  @complete
end

#condition_met_dateObject

Returns the value of attribute condition_met_date.



7
8
9
# File 'lib/riaction/iactionable/objects/progress.rb', line 7

def condition_met_date
  @condition_met_date
end

#current_valueObject

Returns the value of attribute current_value.



8
9
10
# File 'lib/riaction/iactionable/objects/progress.rb', line 8

def current_value
  @current_value
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/riaction/iactionable/objects/progress.rb', line 6

def description
  @description
end

#required_valueObject

Returns the value of attribute required_value.



9
10
11
# File 'lib/riaction/iactionable/objects/progress.rb', line 9

def required_value
  @required_value
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/riaction/iactionable/objects/progress.rb', line 19

def complete?
  Integer(@current_value) >= Integer(@required_value)
rescue TypeError => e
  false
end

#percent_completeObject



25
26
27
28
29
# File 'lib/riaction/iactionable/objects/progress.rb', line 25

def percent_complete
  Integer(Float(@current_value) / Integer(@required_value) * 100)
rescue TypeError => e
  0
end