Sha256: 6e03537c63d26be0a02c128542204a5d9e1b3d7ac1764c3cbe25fc28b336362f

Contents?: true

Size: 740 Bytes

Versions: 82

Compression:

Stored size: 740 Bytes

Contents

# frozen_string_literal: true

module EacRubyUtils
  module Listable
    class Value
      attr_reader :value, :key

      def initialize(list, value, key)
        @list = list
        @value = value
        @key = key
      end

      def to_s
        "I: #{@list.item}, V: #{@value}, K: #{@key}"
      end

      def constant_name
        "#{@list.item}_#{@key}".gsub(/[^a-z0-9_]/, '_').gsub(/_+/, '_')
                               .gsub(/(?:\A_|_\z)/, '').upcase
      end

      def label
        translate('label')
      end

      def description
        translate('description')
      end

      private

      def translate(translate_key)
        ::I18n.t("#{@list.i18n_key}.#{@key}.#{translate_key}")
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 3 rubygems

Version Path
eac_ruby_utils-0.45.0 lib/eac_ruby_utils/listable/value.rb
ehbrs-tools-0.13.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.68.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
eac_ruby_utils-0.44.0 lib/eac_ruby_utils/listable/value.rb
avm-tools-0.67.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.66.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.65.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.64.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.64.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.64.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.63.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.62.4 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.62.3 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.62.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.62.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.62.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.61.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.60.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
avm-tools-0.59.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
eac_ruby_utils-0.43.0 lib/eac_ruby_utils/listable/value.rb