Class: SimpleAMS::Document::Links

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/simple_ams/document/links.rb

Direct Known Subclasses

Forms, Generics, Metas

Defined Under Namespace

Classes: Link

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Links

Returns a new instance of Links.



9
10
11
12
# File 'lib/simple_ams/document/links.rb', line 9

def initialize(options)
  @options = options
  @members = options.links
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
17
18
19
# File 'lib/simple_ams/document/links.rb', line 14

def [](key)
  found = members.find{|link| link.name == key}
  return nil unless found

  return with_decorator(found)
end

#any?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/simple_ams/document/links.rb', line 31

def any?
  members.any?
end

#each(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/simple_ams/document/links.rb', line 21

def each(&block)
  return enum_for(:each) unless block_given?

  members.each{ |member|
    yield with_decorator(member)
  }

  self
end

#empty?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/simple_ams/document/links.rb', line 35

def empty?
  members.empty?
end