Sha256: e2855926e07d2e88917426c855669d561ab155a59e29996d1b1b3a6e88a45422

Contents?: true

Size: 1016 Bytes

Versions: 14

Compression:

Stored size: 1016 Bytes

Contents

class PeakFlowUtils::HandlerText < PeakFlowUtils::ApplicationRecord
  belongs_to :group
  belongs_to :handler
  belongs_to :translation_key

  validates :handler, :translation_key, presence: true

  delegate :key, :last_key, to: :translation_key
  delegate :value, to: :translation, prefix: true
  delegate :array_translation?, :file_line_content, :file_line_content?, :translated_value_for_locale, to: :translation

  def key_show_with_fallback
    key_show.presence || last_key
  end

  def translation
    @translation ||= PeakFlowUtils::Translation.new(
      key: key,
      dir: dir,
      full_path: full_path,
      file_path: file_path,
      line_no: line_no
    )
  end

  def finished?
    @_finished = translation.finished? if @finished.nil?
    @_finished
  end

  def unfinished?
    !finished?
  end

  def array_key
    return unless (match = key.match(/\A(.+)\[(\d+)\]\Z/))

    match[1]
  end

  def array_no
    return unless (match = key.match(/\A(.+)\[(\d+)\]\Z/))

    match[2].to_i
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
peak_flow_utils-0.1.19 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.18 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.17 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.16 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.15 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.14 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.13 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.12 lib/peak_flow_utils/models/handler_text.rb
peak_flow_utils-0.1.11 app/models/peak_flow_utils/handler_text.rb
peak_flow_utils-0.1.10 app/models/peak_flow_utils/handler_text.rb
peak_flow_utils-0.1.9 app/models/peak_flow_utils/handler_text.rb
peak_flow_utils-0.1.8 app/models/peak_flow_utils/handler_text.rb
peak_flow_utils-0.1.7 app/models/peak_flow_utils/handler_text.rb
peak_flow_utils-0.1.6 app/models/peak_flow_utils/handler_text.rb