Class: SimpleAMS::Document::Fields

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

Defined Under Namespace

Classes: Field

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Fields

Returns a new instance of Fields.



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

def initialize(options)
  @options = options
  @members = options.fields #[:field1, :field2]
end

Instance Method Details

#[](key) ⇒ Object



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

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

  value_of(found)
end

#any?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/simple_ams/document/fields.rb', line 32

def any?
  members.any?
end

#each(&block) ⇒ Object

TODO: Can we make this faster?



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

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

  members.each{ |key|
    yield value_of(key)
  }

  self
end

#empty?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/simple_ams/document/fields.rb', line 36

def empty?
  members.empty?
end