Class: Elsmore::Resource
- Inherits:
-
Object
- Object
- Elsmore::Resource
- Defined in:
- lib/elsmore/resource.rb
Instance Attribute Summary collapse
-
#emitter ⇒ Object
Returns the value of attribute emitter.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(url, parent) ⇒ Resource
constructor
A new instance of Resource.
- #write!(nested_urls = false) ⇒ Object
Constructor Details
#initialize(url, parent) ⇒ Resource
7 8 9 10 |
# File 'lib/elsmore/resource.rb', line 7 def initialize url, parent self.url = Elsmore::Url.new(url, parent) self.parent = parent end |
Instance Attribute Details
#emitter ⇒ Object
Returns the value of attribute emitter.
5 6 7 |
# File 'lib/elsmore/resource.rb', line 5 def emitter @emitter end |
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/elsmore/resource.rb', line 5 def filename @filename end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/elsmore/resource.rb', line 5 def parent @parent end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/elsmore/resource.rb', line 5 def url @url end |
Instance Method Details
#data ⇒ Object
21 22 23 |
# File 'lib/elsmore/resource.rb', line 21 def data @data ||= HTTParty.get(url.canonical_url) end |
#write!(nested_urls = false) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/elsmore/resource.rb', line 12 def write! nested_urls = false process_nested_urls if nested_urls writer = Elsmore::Writer.new(self) writer.emitter = emitter writer.write self.filename = writer.canonical_filename end |