Class: Elsmore::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/elsmore/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, parent) ⇒ Resource

Returns a new instance of 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

#emitterObject

Returns the value of attribute emitter.



5
6
7
# File 'lib/elsmore/resource.rb', line 5

def emitter
  @emitter
end

#filenameObject

Returns the value of attribute filename.



5
6
7
# File 'lib/elsmore/resource.rb', line 5

def filename
  @filename
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/elsmore/resource.rb', line 5

def parent
  @parent
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/elsmore/resource.rb', line 5

def url
  @url
end

Instance Method Details

#dataObject



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