Class: Labels::Element

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

Overview

This class is a base class for all document content types

Direct Known Subclasses

Database, Layer, Paper, Template

Instance Method Summary collapse

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_hObject 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