Class: Amline::HpricotTraverser

Inherits:
BlankSlate show all
Defined in:
lib/ruport/util/graph/amline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(some_root) ⇒ HpricotTraverser

Returns a new instance of HpricotTraverser.



110
111
112
# File 'lib/ruport/util/graph/amline.rb', line 110

def initialize(some_root)
  @root = some_root
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ruport/util/graph/amline.rb', line 116

def method_missing(id, *args, &block)
  if id.to_s =~ /^(\w+)=/
    @root.at($1).innerHTML =  args[0].to_s
  elsif id.to_s =~ /^(\w+)!/
    @root.at($1)
  else
    new_root = @root.at(id) or raise
    HpricotTraverser.new(new_root)
  end
rescue
  raise UnknownOption
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



114
115
116
# File 'lib/ruport/util/graph/amline.rb', line 114

def root
  @root
end

Instance Method Details

#==(other) ⇒ Object



129
130
131
# File 'lib/ruport/util/graph/amline.rb', line 129

def ==(other)
  @root == other
end

#inspectObject



133
134
135
# File 'lib/ruport/util/graph/amline.rb', line 133

def inspect
  @root
end

#to_sObject Also known as: to_xml



137
138
139
# File 'lib/ruport/util/graph/amline.rb', line 137

def to_s
  @root.to_s
end