Class: RuBing::Result
- Inherits:
-
Object
- Object
- RuBing::Result
- Defined in:
- lib/rubing.rb
Constant Summary collapse
- REQUIRED_ATTRIBUTES =
%w{title description url}
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(result_hash) ⇒ Result
constructor
A new instance of Result.
-
#method_missing(method_name, *args, &block) ⇒ Object
So in some unknown situations Bing does not return some attributes!.
Constructor Details
#initialize(result_hash) ⇒ Result
Returns a new instance of Result.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/rubing.rb', line 146 def initialize(result_hash) @data = result_hash result_hash.each_pair do |key, value| next if key == "SearchTags" || key == "DeepLinks" # not sure why this is returned. I don't want it :p begin instance_eval(<<-EOS, __FILE__, __LINE__) def #{Result.rubyize(key)} #{value.dump} end EOS rescue Exception => e puts "Bad Key: '#{key}' #{e.}" puts result_hash.inspect end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
So in some unknown situations Bing does not return some attributes!
164 165 166 167 |
# File 'lib/rubing.rb', line 164 def method_missing(method_name, *args, &block) return "" if REQUIRED_ATTRIBUTES.include?(method_name.to_s) raise NoMethodError end |
Instance Method Details
#data ⇒ Object
169 170 171 |
# File 'lib/rubing.rb', line 169 def data @data end |