Class: Internode::Resource
- Inherits:
-
Object
- Object
- Internode::Resource
- Defined in:
- lib/internode/resource.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/internode/resource.rb', line 3 def client @client end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/internode/resource.rb', line 3 def path @path end |
Class Method Details
.content_attr(*names) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/internode/resource.rb', line 15 def content_attr(*names) names.each do |name| name = name.to_s method_name = name.gsub(/\W+/, "_") define_method(method_name) do content.at_css(name).text end end end |
Instance Method Details
#content ⇒ Object
10 11 12 |
# File 'lib/internode/resource.rb', line 10 def content @content ||= @client.get(path) end |