Sha256: 964c02d4c3f8f819146354b1aaac2c3accf110e0d1c88ca0ae7c38a072e71745
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
# encoding: UTF-8 module Rosette module Core module Commands # Represents an added, removed, or changed phrase. # # @!attribute [r] phrase # @return [Rosette::Core::Phrase] the added/removed/modified phrase. # @!attribute [r] state # @return [Symbol] one of +:added+, +:removed+, or +:modified+. # @!attribute [r] old_phrase # @return [Rosette::Core::Phrase] +phrase+ before it was modified. # This value is generally only set if +state+ is set to +:modified+. class DiffEntry attr_reader :phrase, :state, :old_phrase # Creates a new {DiffEntry}. # # @param [Rosette::Core::Phrase] phrase The added/removed/modified phrase. # @param [Symbol] state One of +:added+, +:removed+, or +:modified+. # @param [Rosette::Core::Phrase] old_phrase +phrase+ before it was modified. # This argument is usually only included if +state+ is +:modified+. def initialize(phrase, state, old_phrase = nil) @phrase = phrase @state = state @old_phrase = old_phrase end # Serializes the attributes of this entry into a hash. # # @return [Hash] the attributes of the phrase. If +state+ is set to +:modified+, # the key of the old phrase is included as +:old_key+. def to_h phrase.to_h.tap do |hash| hash[:old_key] = old_phrase.key if old_phrase end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rosette-core-1.0.1 | lib/rosette/core/commands/git/diff_entry.rb |