Class: XMLResume2x::ElementWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlresume2x/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, processor, options) ⇒ ElementWrapper

Returns a new instance of ElementWrapper.



71
72
73
74
75
# File 'lib/xmlresume2x/wrapper.rb', line 71

def initialize( element, processor, options )
  @element = element
  @processor = processor
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/xmlresume2x/wrapper.rb', line 77

def method_missing( name, *args )
  name = name.to_s
  if name =~ /^_/
    name.sub!( /^_/, '' )
    @processor.get_value( @element.attributes[name], @options )
  elsif @element.elements[name]
    list = ElementWrapperList.new
    @element.each_element( name ) {|e| list << ElementWrapper.new( e, @processor, @options ) }
    list
  else
    nil
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



69
70
71
# File 'lib/xmlresume2x/wrapper.rb', line 69

def options
  @options
end

Instance Method Details

#__elementObject



91
92
93
# File 'lib/xmlresume2x/wrapper.rb', line 91

def __element
  @element
end

#process!(options = {}) ⇒ Object



95
96
97
# File 'lib/xmlresume2x/wrapper.rb', line 95

def process!( options = {} )
  @processor.get_value( self, options )
end

#process_children!(options = {}) ⇒ Object



99
100
101
# File 'lib/xmlresume2x/wrapper.rb', line 99

def process_children!( options = {} )
  @processor.get_children_value( self, options )
end

#text!Object



103
104
105
# File 'lib/xmlresume2x/wrapper.rb', line 103

def text!
  @processor.get_value( @element.text, @options )
end

#to_sObject



107
108
109
# File 'lib/xmlresume2x/wrapper.rb', line 107

def to_s
  process!.to_s
end