Class: Sunniesnow::Charter::Event
- Inherits:
-
Object
- Object
- Sunniesnow::Charter::Event
show all
- Includes:
- Metronomic
- Defined in:
- lib/sscharter/charter/event.rb
Constant Summary
collapse
- TIP_POINTABLE_TYPES =
The types (#type) of events that
should be considered possibly visited by a tip point from the charting perspective.
They affect #tip_pointable? and suggests whether this event should be visited by a tip point
if it is created inside blocks in Sunniesnow::Charter#tip_point_chain and Sunniesnow::Charter#tip_point_drop.
For this reason, although placeholder events can be visited by a tip point from a technical perspective,
it is not included in this list.
%i[tap hold flick drag drag_flick].freeze
- TIP_POINTABLE_TYPES_SET =
TIP_POINTABLE_TYPES.to_set.freeze
Instance Attribute Summary collapse
Attributes included from Metronomic
#beat, #bpm_changes, #duration_beats, #offset
Instance Method Summary
collapse
Methods included from Metronomic
#<=>, #beat_state, #end_time, #time, #time_at_relative_beat
Constructor Details
#initialize(type, beat, duration_beats = nil, bpm_changes, **properties) ⇒ Event
Returns a new instance of Event.
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/sscharter/charter/event.rb', line 39
def initialize type, beat, duration_beats = nil, bpm_changes, **properties
@beat = beat
@duration_beats = duration_beats
@type = type
@bpm_changes = bpm_changes
@properties = properties
@time_dependent = TimeDependent.new beat, bpm_changes
@offset = 0.0
@backtrace = caller.filter { _1.sub! /^#{PROJECT_DIR}\//, '' }
end
|
Instance Attribute Details
#backtrace ⇒ Array<String>
32
33
34
|
# File 'lib/sscharter/charter/event.rb', line 32
def backtrace
@backtrace
end
|
#properties ⇒ Hash{Symbol => Numeric, String}
26
27
28
|
# File 'lib/sscharter/charter/event.rb', line 26
def properties
@properties
end
|
29
30
31
|
# File 'lib/sscharter/charter/event.rb', line 29
def time_dependent
@time_dependent
end
|
#type ⇒ Symbol
23
24
25
|
# File 'lib/sscharter/charter/event.rb', line 23
def type
@type
end
|
Instance Method Details
#[](key) ⇒ Numeric, String
52
53
54
|
# File 'lib/sscharter/charter/event.rb', line 52
def [] key
@properties[key]
end
|
#[]=(key, value) ⇒ Numeric, String
59
60
61
|
# File 'lib/sscharter/charter/event.rb', line 59
def []= key, value
@properties[key] = value
end
|
TODO: use initialize_copy.
75
76
77
78
79
80
|
# File 'lib/sscharter/charter/event.rb', line 75
def dup
result = super
result.properties = @properties.dup
result.time_dependent = @time_dependent.dup
result
end
|
#inspect ⇒ String
90
91
92
93
|
# File 'lib/sscharter/charter/event.rb', line 90
def inspect
"#<#@type at #@beat#{@duration_beats && " for #@duration_beats"} offset #@offset: " +
@properties.map { |k, v| "#{k}=#{v.inspect}" }.join(', ') + '>'
end
|
#tip_pointable? ⇒ Boolean
85
86
87
|
# File 'lib/sscharter/charter/event.rb', line 85
def tip_pointable?
TIP_POINTABLE_TYPES_SET.include? @type
end
|
64
65
66
67
68
69
70
71
|
# File 'lib/sscharter/charter/event.rb', line 64
def to_sunniesnow
t = time
properties = @properties.transform_keys &:snake_to_camel
properties[:duration] = end_time - t if @duration_beats
result = Sunniesnow::Event.new t, @type.snake_to_camel, **properties
result.time_dependent = @time_dependent.to_sunniesnow unless @time_dependent.empty?
result
end
|