Class: Spread2RDF::Schema::Element

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Attributes
Defined in:
lib/spread2rdf/schema/element.rb

Direct Known Subclasses

Column, Sheet

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

#init_attributes, #inspect, #update_attributes

Constructor Details

#initialize(parent, attr = {}, &block) ⇒ Element

Returns a new instance of Element.



19
20
21
22
23
# File 'lib/spread2rdf/schema/element.rb', line 19

def initialize(parent, attr = {}, &block)
  @parent   = parent
  @block    = block
  init_attributes(attr)
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



15
16
17
# File 'lib/spread2rdf/schema/element.rb', line 15

def block
  @block
end

#parentObject (readonly)

Returns the value of attribute parent.



14
15
16
# File 'lib/spread2rdf/schema/element.rb', line 14

def parent
  @parent
end

Instance Method Details

#nameObject



25
26
27
# File 'lib/spread2rdf/schema/element.rb', line 25

def name
  (@name or @source_name).try(:to_sym)
end

#source_nameObject



29
30
31
# File 'lib/spread2rdf/schema/element.rb', line 29

def source_name
  (@source_name or @name).try(:to_s)
end

#to_sObject



40
41
42
43
44
# File 'lib/spread2rdf/schema/element.rb', line 40

def to_s
  name = (self.name.to_s == self.source_name.to_s ?
      self.name : "#{self.name} (#{self.source_name})" )
  "#{self.class.name.split('::').last}-schema #{name}"
end

#worksheetObject



33
34
35
36
37
38
# File 'lib/spread2rdf/schema/element.rb', line 33

def worksheet
  return self if self.is_a? Worksheet
  parent = self.parent
  parent = parent.parent until parent.is_a? Worksheet or parent.nil?
  parent
end