Class: IActionable::Objects::Progress
- Inherits:
-
IActionableObject
- Object
- IActionableObject
- IActionable::Objects::Progress
- Defined in:
- lib/iactionable/objects/progress.rb
Instance Attribute Summary collapse
-
#complete ⇒ Object
readonly
Returns the value of attribute complete.
-
#condition_met_date ⇒ Object
Returns the value of attribute condition_met_date.
-
#current_value ⇒ Object
Returns the value of attribute current_value.
-
#description ⇒ Object
Returns the value of attribute description.
-
#original_condition_met_date ⇒ Object
Returns the value of attribute original_condition_met_date.
-
#required_value ⇒ Object
Returns the value of attribute required_value.
Instance Method Summary collapse
- #complete? ⇒ Boolean
-
#initialize(key_values = {}) ⇒ Progress
constructor
A new instance of Progress.
- #percent_complete ⇒ Object
- #to_hash ⇒ Object
Methods inherited from IActionableObject
timestamp_regexp, timestamp_to_seconds
Constructor Details
#initialize(key_values = {}) ⇒ Progress
Returns a new instance of Progress.
11 12 13 14 15 16 17 |
# File 'lib/iactionable/objects/progress.rb', line 11 def initialize(key_values={}) super(key_values) # convert the miliseconds within the date string to seconds (per ruby) # "/Date(1275706032317-0600)/" => "1275706032-0600" @original_condition_met_date = @condition_met_date @condition_met_date = IActionableObject.(@condition_met_date) unless @condition_met_date.blank? end |
Instance Attribute Details
#complete ⇒ Object (readonly)
Returns the value of attribute complete.
9 10 11 |
# File 'lib/iactionable/objects/progress.rb', line 9 def complete @complete end |
#condition_met_date ⇒ Object
Returns the value of attribute condition_met_date.
5 6 7 |
# File 'lib/iactionable/objects/progress.rb', line 5 def condition_met_date @condition_met_date end |
#current_value ⇒ Object
Returns the value of attribute current_value.
7 8 9 |
# File 'lib/iactionable/objects/progress.rb', line 7 def current_value @current_value end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/iactionable/objects/progress.rb', line 4 def description @description end |
#original_condition_met_date ⇒ Object
Returns the value of attribute original_condition_met_date.
6 7 8 |
# File 'lib/iactionable/objects/progress.rb', line 6 def original_condition_met_date @original_condition_met_date end |
#required_value ⇒ Object
Returns the value of attribute required_value.
8 9 10 |
# File 'lib/iactionable/objects/progress.rb', line 8 def required_value @required_value end |
Instance Method Details
#complete? ⇒ Boolean
19 20 21 22 23 |
# File 'lib/iactionable/objects/progress.rb', line 19 def complete? Integer(@current_value) >= Integer(@required_value) rescue TypeError => e false end |
#percent_complete ⇒ Object
25 26 27 28 29 |
# File 'lib/iactionable/objects/progress.rb', line 25 def percent_complete Integer(Float(@current_value) / Integer(@required_value) * 100) rescue TypeError => e 0 end |
#to_hash ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/iactionable/objects/progress.rb', line 36 def to_hash { "Description" => @description, "CurrentValue" => @current_value, "RequiredValue" => @required_value, "ConditionMetDate" => @original_condition_met_date } end |