Class: IActionable::Objects::IActionableObject

Inherits:
Object
  • Object
show all
Defined in:
lib/iactionable/objects/i_actionable_object.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_values = {}) ⇒ IActionableObject

Returns a new instance of IActionableObject.



4
5
6
7
8
# File 'lib/iactionable/objects/i_actionable_object.rb', line 4

def initialize(key_values={})
  key_values.each_pair do |key, value|
    instance_variable_set "@#{key.camelize.underscore}".to_sym, value
  end
end

Class Method Details

.timestamp_regexpObject



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

def self.timestamp_regexp
  /\/Date\((\d+)((\-|\+)\d{4})\)\//
end

.timestamp_to_seconds(timestamp) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/iactionable/objects/i_actionable_object.rb', line 14

def self.timestamp_to_seconds(timestamp)
  milliseconds = timestamp[timestamp_regexp, 1]
  tz = timestamp[timestamp_regexp, 2]
  unless milliseconds.nil? || tz.nil?
    "#{Integer(milliseconds)/1000}#{tz}"
  else
    nil
  end
end