Class: Labels::Element
- Inherits:
-
Object
- Object
- Labels::Element
- Defined in:
- lib/labels/element.rb
Overview
This class is a base class for all document content types
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ Element
constructor
Creates a new Labels::Element instance with given arguments.
-
#to_h ⇒ Object
(also: #to_hash)
Converts instance variables to hash.
Constructor Details
#initialize(args = nil) ⇒ Element
Creates a new Labels::Element instance with given arguments
13 14 15 16 17 18 19 |
# File 'lib/labels/element.rb', line 13 def initialize(args=nil) unless args.nil? args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end end |
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
Converts instance variables to hash
22 23 24 25 26 |
# File 'lib/labels/element.rb', line 22 def to_h hash = {} self.instance_variables.each {|var| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var) } hash end |