Eno::Field » #value

value → value or nil
value(options) → value or nil
value(loader_proc, options) → value or nil
value(options) { |name, value| loader } → value or nil

Retrieve the value of an Eno::Field, optionally passing it through a loader block or Proc and/or supplying options.

enoflag color: beige
towel color:
rubydocument = Eno.parse(input)

flag_color = document.element('flag color')
towel_color = document.element('towel color')

flag_color.value  # => 'beige'
towel_color.value  # => nil

flag_color.value(Proc.new { |name, value| value.gsub('eig', 'lu') })   #=> 'blue'

flag_color.value do |name, value|
  value.gsub('eig', 'lu')
end  #=> 'blue'


loader_block or loader_proc

A block or proc returning the transformed/validated value or raising an error.The block or proc's argument signature is dynamic, you can either use |value|or |name, value| depending on your needs.



Whether there must be a value or the field is allowed to be empty (default to false)


Alias for enforce_value (this exists on many methods and depending on context refers to either element or value)

Return value

The (optionally transformed/validated) value of this Eno::Field.