Class: Medie::Xml::Links
- Inherits:
-
Object
show all
- Defined in:
- lib/medie/xml/links.rb
Instance Method Summary
collapse
Constructor Details
#initialize(links) ⇒ Links
Returns a new instance of Links.
5
6
7
8
9
10
11
12
13
|
# File 'lib/medie/xml/links.rb', line 5
def initialize(links)
@hash = {}
links = [links] unless links.kind_of? Array
links = [] unless links
links.each { |l|
link = Medie::Link.new(l)
@hash[link.rel.to_s] = link
}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
27
28
29
30
|
# File 'lib/medie/xml/links.rb', line 27
def method_missing(sym, *args)
raise "Links can not receive arguments" unless args.empty?
self[sym.to_s]
end
|
Instance Method Details
#[](name) ⇒ Object
15
16
17
|
# File 'lib/medie/xml/links.rb', line 15
def [](name)
@hash[name]
end
|
#keys ⇒ Object
23
24
25
|
# File 'lib/medie/xml/links.rb', line 23
def keys
@hash.keys
end
|
#size ⇒ Object
19
20
21
|
# File 'lib/medie/xml/links.rb', line 19
def size
@hash.size
end
|