Class: Kvn::Converter
- Inherits:
-
Object
- Object
- Kvn::Converter
- Defined in:
- lib/kvn/converter.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(value) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(value) ⇒ Converter
Returns a new instance of Converter.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kvn/converter.rb', line 7 def initialize(value) @value = begin (value || {}).to_h rescue {} end if invalid_values_present? = "All values must be a supported type! #{Kvn::SUPPORTED_VALUE_TYPES.join ", "}" raise Kvn::UnsupportedHashError.new() end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/kvn/converter.rb', line 5 def value @value end |
Instance Method Details
#convert ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/kvn/converter.rb', line 20 def convert value.keys.sort.each_with_object([]) { |key, memo| v = value[key] v = "null" if v.nil? next if v.to_s.strip.empty? memo << "#{key}:#{v};" }.join(" ") end |