Sha256: 7af59ffb7961ff35860b1ceb94a96227f1ba7d8e4f2b041ea16ccf3178780b65

Contents?: true

Size: 789 Bytes

Versions: 2

Compression:

Stored size: 789 Bytes

Contents

# Namespace for the Opushon library.
module Opushon
  # Parse a Opushon string in opushon.
  class RestrictedValue
    attr_reader :value

    def self.load_list(restricted_values)
      return if restricted_values.nil?

      restricted_values.map do |restricted_value|
        new(JSON.parse(restricted_value.to_json, symbolize_names: true)).to_h
      end
    end

    def initialize( title:        '',
                    description:  '',
                    value:          )

      @title        = title.to_s
      @description  = description.to_s
      @value        = value

      freeze
    end

    # Dump instance's opushon to a hash.
    def to_h
      {
        title:        @title,
        description:  @description,
        value:        @value
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opushon-0.1.1 lib/opushon/restricted_value.rb
opushon-0.1.0 lib/opushon/restricted_value.rb