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.
11 12 13 14 15 |
# File 'lib/sub_diff/collection.rb', line 11 def initialize(string) @string = string @diffs = [] super(string) end |
Instance Attribute Details
#diffs ⇒ Object (readonly)
Returns the value of attribute diffs.
9 10 11 |
# File 'lib/sub_diff/collection.rb', line 9 def diffs @diffs end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
9 10 11 |
# File 'lib/sub_diff/collection.rb', line 9 def string @string end |
Instance Method Details
#changed? ⇒ Boolean
17 18 19 |
# File 'lib/sub_diff/collection.rb', line 17 def changed? diffs.any?(&:changed?) end |
#clear ⇒ Object
21 22 23 24 25 |
# File 'lib/sub_diff/collection.rb', line 21 def clear diffs.clear __setobj__('') self end |
#push(diff) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/sub_diff/collection.rb', line 27 def push(diff) unless diff.empty? diffs << diff __setobj__(diffs.join) end end |
#reset ⇒ Object
34 35 36 37 38 39 |
# File 'lib/sub_diff/collection.rb', line 34 def reset clear __setobj__(string) yield if block_given? self end |