Class: Whereby::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/whereby/element.rb

Direct Known Subclasses

Meeting

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Element

Returns a new instance of Element.



3
4
5
6
# File 'lib/whereby/element.rb', line 3

def initialize(attrs = {})
  # Only set attributes if the method exists
  attrs.each{ |k,v| send("#{k.underscore}=", v) if respond_to?("#{k.underscore}") }
end

Instance Method Details

#to_hObject



8
9
10
11
12
13
14
15
# File 'lib/whereby/element.rb', line 8

def to_h
  Hash[
      *instance_variables.map do |variable|
        name = variable[1..-1].to_sym #Removing @
        [name, instance_variable_get(variable)]
      end.flatten
  ]
end