Class: Enolib::Field
Instance Method Summary
collapse
#value_error
Methods inherited from ElementBase
#comment_error, #error, #initialize, #key, #key_error, #optional_comment, #optional_string_comment, #raw, #required_comment, #required_string_comment, #string_key, #touch
Instance Method Details
#optional_string_value ⇒ Object
5
6
7
|
# File 'lib/enolib/elements/field.rb', line 5
def optional_string_value
_value(required: false)
end
|
#optional_value(loader = nil) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/enolib/elements/field.rb', line 9
def optional_value(loader = nil)
loader = Proc.new if block_given?
unless loader
raise ArgumentError, 'A loader function must be provided'
end
_value(loader, required: false)
end
|
#parent ⇒ Object
19
20
21
|
# File 'lib/enolib/elements/field.rb', line 19
def parent
@parent || Section.new(@context, @instruction[:parent])
end
|
#required_string_value ⇒ Object
23
24
25
|
# File 'lib/enolib/elements/field.rb', line 23
def required_string_value
_value(required: true)
end
|
#required_value(loader = nil) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/enolib/elements/field.rb', line 27
def required_value(loader = nil)
loader = Proc.new if block_given?
unless loader
raise ArgumentError, 'A loader function must be provided'
end
_value(loader, required: true)
end
|
#to_s ⇒ Object
37
38
39
|
# File 'lib/enolib/elements/field.rb', line 37
def to_s
"#<Enolib::Field key=#{@instruction[:key]} value=#{print_value}>"
end
|