Class: Tonal::Ratio::Approximation::Set
- Inherits:
-
Object
- Object
- Tonal::Ratio::Approximation::Set
- Extended by:
- Forwardable
- Defined in:
- lib/tonal/approximation.rb
Instance Attribute Summary collapse
-
#ratio ⇒ Object
readonly
Returns the value of attribute ratio.
-
#ratios ⇒ Object
readonly
Returns the value of attribute ratios.
Instance Method Summary collapse
-
#initialize(ratio:) {|@ratios| ... } ⇒ Set
constructor
A new instance of Set.
- #inspect ⇒ Object
- #sort_by ⇒ Object
Constructor Details
#initialize(ratio:) {|@ratios| ... } ⇒ Set
Returns a new instance of Set.
159 160 161 162 163 |
# File 'lib/tonal/approximation.rb', line 159 def initialize(ratio:) @ratio = ratio @ratios = ::Set.new yield @ratios if block_given? end |
Instance Attribute Details
#ratio ⇒ Object (readonly)
Returns the value of attribute ratio.
157 158 159 |
# File 'lib/tonal/approximation.rb', line 157 def ratio @ratio end |
#ratios ⇒ Object (readonly)
Returns the value of attribute ratios.
157 158 159 |
# File 'lib/tonal/approximation.rb', line 157 def ratios @ratios end |
Instance Method Details
#inspect ⇒ Object
166 167 168 |
# File 'lib/tonal/approximation.rb', line 166 def inspect "#{ratio}: #{entries}" end |
#sort_by ⇒ Object
170 171 172 173 174 175 176 |
# File 'lib/tonal/approximation.rb', line 170 def sort_by(&) self.class.new(ratio: ratio) do |ratios| entries.sort_by(&).each do |ratio| ratios << ratio end end end |