Class: SubDiff::Collection
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SubDiff::Collection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/sub_diff/collection.rb
Instance Attribute Summary collapse
-
#diffs ⇒ Object
readonly
Returns the value of attribute diffs.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #changed? ⇒ Boolean
- #clear ⇒ Object
-
#initialize(string) ⇒ Collection
constructor
A new instance of Collection.
- #push(diff) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(string) ⇒ Collection
Returns a new instance of Collection.
10 11 12 13 14 |
# File 'lib/sub_diff/collection.rb', line 10 def initialize(string) @string = string @diffs = [] super(string) end |
Instance Attribute Details
#diffs ⇒ Object (readonly)
Returns the value of attribute diffs.
8 9 10 |
# File 'lib/sub_diff/collection.rb', line 8 def diffs @diffs end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
8 9 10 |
# File 'lib/sub_diff/collection.rb', line 8 def string @string end |
Instance Method Details
#changed? ⇒ Boolean
16 17 18 |
# File 'lib/sub_diff/collection.rb', line 16 def changed? diffs.any?(&:changed?) end |
#clear ⇒ Object
20 21 22 23 24 |
# File 'lib/sub_diff/collection.rb', line 20 def clear diffs.clear __setobj__('') self end |
#push(diff) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/sub_diff/collection.rb', line 26 def push(diff) unless diff.empty? diffs << diff __setobj__(diffs.join) end end |
#reset ⇒ Object
33 34 35 36 37 38 |
# File 'lib/sub_diff/collection.rb', line 33 def reset clear __setobj__(string) yield if block_given? self end |