Sha256: c8671d2fe80ae039c33810493c83c91eea1c57e0e9f16eddaa8373a407517d81

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

# encoding: UTF-8

module Rosette
  module Core

    # Turns a {Phrase} into a hash. Must be mixed into a {Phrase}-like class.
    #
    # @example
    #   p = Phrase.new
    #   p.key = 'foo'
    #   p.meta_key = 'bar'
    #   p.file = '/path/to/file.yml'
    #
    #   p.to_h  # => { key: 'foo', meta_key: 'bar', file: '/path/to/file.yml' ... }
    module PhraseToHash
      # Converts the attributes of a {Phrase} into a hash of attributes.
      #
      # @return [Hash] a hash of phrase attributes.
      def to_h
        {
          key: key,
          meta_key: meta_key,
          file: file,
          commit_id: commit_id,
          author_name: author_name,
          author_email: author_email,
          line_number: line_number
        }
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rosette-core-1.0.1 lib/rosette/core/extractor/phrase/phrase_to_hash.rb