Class: Claire::Client::List

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/claire_client/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg, klass = nil) ⇒ List

gets, parses, and builds objects.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/claire_client/list.rb', line 9

def initialize(arg, klass=nil)								
	@body = Claire::Client.get(arg)
	@document = Hashie::Mash.new(Hashie::Mash.from_xml(@body))
	@document = @document.rss if @document.rss
	@document = @document.channel if @document.channel				
	if @document.item.nil?
		@items = []
	elsif @document.item.is_a? Array
		@items = @document.item
	else					
		@items = [@document.item]
	end
	@klass = klass
	build_items											
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/claire_client/list.rb', line 6

def body
  @body
end

#documentObject (readonly)

Returns the value of attribute document.



6
7
8
# File 'lib/claire_client/list.rb', line 6

def document
  @document
end

Instance Method Details

#each(&block) ⇒ Object

Implements an iterator that either

  • returns an Array of items if no block is given

  • yields the given block once for each item



28
29
30
31
32
33
# File 'lib/claire_client/list.rb', line 28

def each &block
	return @objects unless block
	@objects.each do |obj|
		yield(obj)
	end
end