Class: Purdie::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/purdie/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Item

Returns a new instance of Item.



5
6
7
8
# File 'lib/purdie/item.rb', line 5

def initialize url
  @url = url
  @datas = {}
end

Instance Attribute Details

#datasObject (readonly)

Returns the value of attribute datas.



3
4
5
# File 'lib/purdie/item.rb', line 3

def datas
  @datas
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/purdie/item.rb', line 3

def url
  @url
end

Instance Method Details

#[](key) ⇒ Object



18
19
20
# File 'lib/purdie/item.rb', line 18

def [] key
  @datas[key]
end

#[]=(key, value) ⇒ Object



14
15
16
# File 'lib/purdie/item.rb', line 14

def []= key, value
  @datas[key] = value
end

#distillObject



10
11
12
# File 'lib/purdie/item.rb', line 10

def distill
  @datas = service.distill @url
end

#serviceObject



22
23
24
25
# File 'lib/purdie/item.rb', line 22

def service
  c = Service.services.select { |s| url =~ /#{s.matcher}/ }.first
  c.new
end

#to_yamlObject



27
28
29
30
# File 'lib/purdie/item.rb', line 27

def to_yaml
  Purdie.debug 'wtf'
  @datas.to_yaml
end