Class: SimpleAMS::Document::Fields
- Inherits:
-
Object
- Object
- SimpleAMS::Document::Fields
- Includes:
- Enumerable
- Defined in:
- lib/simple_ams/document/fields.rb
Defined Under Namespace
Classes: Field
Instance Method Summary collapse
- #[](key) ⇒ Object
- #any? ⇒ Boolean
-
#each ⇒ Object
TODO: Can we make this faster?.
- #empty? ⇒ Boolean
-
#initialize(options) ⇒ Fields
constructor
A new instance of Fields.
Constructor Details
#initialize(options) ⇒ Fields
Returns a new instance of Fields.
8 9 10 11 |
# File 'lib/simple_ams/document/fields.rb', line 8 def initialize() @options = @members = .fields # [:field1, :field2] end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/simple_ams/document/fields.rb', line 13 def [](key) found = members.find { |field| field == key } return nil unless found value_of(found) end |
#any? ⇒ Boolean
31 32 33 |
# File 'lib/simple_ams/document/fields.rb', line 31 def any? members.any? end |
#each ⇒ Object
TODO: Can we make this faster?
21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_ams/document/fields.rb', line 21 def each return enum_for(:each) unless block_given? members.each do |key| yield value_of(key) end self end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/simple_ams/document/fields.rb', line 35 def empty? members.empty? end |