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.



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

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



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

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.



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

def root
  @root
end

Instance Method Details

#==(other) ⇒ Object



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

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

#inspectObject



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

def inspect
  @root
end

#to_sObject Also known as: to_xml



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

def to_s
  @root.to_s
end