Class: Musa::Neumas::Decoders::Decoder

Inherits:
DifferentialDecoder show all
Defined in:
lib/musa-dsl/neumas/neuma-decoder.rb

Direct Known Subclasses

NeumaDecoder

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DifferentialDecoder

#process

Constructor Details

#initialize(base, transcriptor: nil) ⇒ Decoder

Returns a new instance of Decoder.



26
27
28
29
30
31
# File 'lib/musa-dsl/neumas/neuma-decoder.rb', line 26

def initialize(base, transcriptor: nil)
  @base = base
  @last = base.clone

  @transcriptor = transcriptor
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



34
35
36
# File 'lib/musa-dsl/neumas/neuma-decoder.rb', line 34

def base
  @base
end

#transcriptorObject

Returns the value of attribute transcriptor.



33
34
35
# File 'lib/musa-dsl/neumas/neuma-decoder.rb', line 33

def transcriptor
  @transcriptor
end

Instance Method Details

#apply(_action, on:) ⇒ Object

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/musa-dsl/neumas/neuma-decoder.rb', line 57

def apply(_action, on:)
  raise NotImplementedError
end

#decode(attributes) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/musa-dsl/neumas/neuma-decoder.rb', line 45

def decode(attributes)
  result = apply process(attributes), on: @last

  @last = result.clone

  if @transcriptor
    @transcriptor.transcript(result)
  else
    result
  end
end

#subcontextObject



41
42
43
# File 'lib/musa-dsl/neumas/neuma-decoder.rb', line 41

def subcontext
  Decoder.new @base
end