Class: Canopus::Patch::Composite
- Inherits:
-
Object
- Object
- Canopus::Patch::Composite
- Defined in:
- lib/canopus/patch/composite.rb,
sig/canopus.rbs
Instance Attribute Summary collapse
-
#patches ⇒ Array[patch]
readonly
Returns the value of attribute patches.
Instance Method Summary collapse
- #after ⇒ rope
- #before ⇒ rope
- #compose(other) ⇒ Composite
- #edits ⇒ Array[Edit]
-
#initialize(patches) ⇒ Composite
constructor
A new instance of Composite.
- #inverse ⇒ Composite
- #map_offset(offset, bias: :right) ⇒ Integer
Constructor Details
#initialize(patches) ⇒ Composite
Returns a new instance of Composite.
5 |
# File 'lib/canopus/patch/composite.rb', line 5 def initialize(patches) = @patches = patches.freeze |
Instance Attribute Details
#patches ⇒ Array[patch] (readonly)
Returns the value of attribute patches.
4 5 6 |
# File 'lib/canopus/patch/composite.rb', line 4 def patches @patches end |
Instance Method Details
#after ⇒ rope
7 |
# File 'lib/canopus/patch/composite.rb', line 7 def after = patches.last.after |
#before ⇒ rope
6 |
# File 'lib/canopus/patch/composite.rb', line 6 def before = patches.first.before |
#compose(other) ⇒ Composite
11 |
# File 'lib/canopus/patch/composite.rb', line 11 def compose(other) = self.class.new([*patches, other]) |
#edits ⇒ Array[Edit]
8 |
# File 'lib/canopus/patch/composite.rb', line 8 def edits = patches.flat_map(&:edits) |
#inverse ⇒ Composite
10 |
# File 'lib/canopus/patch/composite.rb', line 10 def inverse = self.class.new(patches.reverse.map(&:inverse)) |
#map_offset(offset, bias: :right) ⇒ Integer
9 |
# File 'lib/canopus/patch/composite.rb', line 9 def map_offset(offset, bias: :right) = patches.reduce(offset) { |position, patch| patch.map_offset(position, bias: bias) } |