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.
5 6 7 8 9 10 11 12 |
# File 'lib/kvn/converter.rb', line 5 def initialize(value) @value = (value ||= {}).to_h rescue {} 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.
3 4 5 |
# File 'lib/kvn/converter.rb', line 3 def value @value end |
Instance Method Details
#convert ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/kvn/converter.rb', line 14 def convert value.keys.sort.each_with_object([]) do |key, memo| v = value[key] v = "null" if v.nil? next if v.to_s.strip.empty? memo << "#{key}:#{v};" end.join(" ") end |