Class: Herb::DiffResult
- Inherits:
-
Object
- Object
- Herb::DiffResult
- Includes:
- Enumerable
- Defined in:
- lib/herb/diff_result.rb
Instance Attribute Summary collapse
-
#operations ⇒ Object
readonly
: Array.
Instance Method Summary collapse
-
#changed? ⇒ Boolean
: () -> bool.
-
#each(&block) ⇒ Object
: () { (Herb::DiffOperation) -> void } -> void : () -> Enumerator[Herb::DiffOperation, void].
-
#identical? ⇒ Boolean
: () -> bool.
-
#initialize(identical, operations) ⇒ DiffResult
constructor
: (bool, Array) -> void.
-
#inspect ⇒ Object
: () -> String.
-
#operation_count ⇒ Object
: () -> Integer.
-
#to_hash ⇒ Object
(also: #to_h)
: () -> Hash[Symbol, untyped].
Constructor Details
#initialize(identical, operations) ⇒ DiffResult
: (bool, Array) -> void
11 12 13 14 15 |
# File 'lib/herb/diff_result.rb', line 11 def initialize(identical, operations) @identical = identical @operations = operations.freeze freeze end |
Instance Attribute Details
#operations ⇒ Object (readonly)
: Array
8 9 10 |
# File 'lib/herb/diff_result.rb', line 8 def operations @operations end |
Instance Method Details
#changed? ⇒ Boolean
: () -> bool
36 37 38 |
# File 'lib/herb/diff_result.rb', line 36 def changed? !identical? end |
#each(&block) ⇒ Object
: () { (Herb::DiffOperation) -> void } -> void : () -> Enumerator[Herb::DiffOperation, void]
19 20 21 22 23 |
# File 'lib/herb/diff_result.rb', line 19 def each(&block) return operations.each unless block operations.each(&block) end |
#identical? ⇒ Boolean
: () -> bool
26 27 28 |
# File 'lib/herb/diff_result.rb', line 26 def identical? @identical end |
#inspect ⇒ Object
: () -> String
51 52 53 54 55 56 57 |
# File 'lib/herb/diff_result.rb', line 51 def inspect if identical? "#<#{self.class.name} identical>" else "#<#{self.class.name} #{operation_count} operation#{"s" unless operation_count == 1}>" end end |
#operation_count ⇒ Object
: () -> Integer
31 32 33 |
# File 'lib/herb/diff_result.rb', line 31 def operation_count operations.size end |
#to_hash ⇒ Object Also known as: to_h
: () -> Hash[Symbol, untyped]
41 42 43 44 45 46 |
# File 'lib/herb/diff_result.rb', line 41 def to_hash { identical: identical?, operations: operations.map(&:to_hash), } end |