Class: WTFChord::Formatters::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/wtf_chord/formatters/base.rb

Direct Known Subclasses

Default, Simple

Constant Summary collapse

FRETS =
6

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fret, with_rates = false) ⇒ Base

Returns a new instance of Base.



26
27
28
29
# File 'lib/wtf_chord/formatters/base.rb', line 26

def initialize(fret, with_rates = false)
  @fret = fret
  @with_rates = !!with_rates
end

Class Method Details

.separatorObject



11
12
13
# File 'lib/wtf_chord/formatters/base.rb', line 11

def self.separator
  "\n".freeze
end

.to_procObject



15
16
17
# File 'lib/wtf_chord/formatters/base.rb', line 15

def self.to_proc
  proc { |fret| new(fret, Thread.current[:with_rates]).draw }
end

.with_rates(value = false) ⇒ Object



19
20
21
22
23
24
# File 'lib/wtf_chord/formatters/base.rb', line 19

def self.with_rates(value = false)
  Thread.current[:with_rates], with_rates_was = !!value, !!Thread.current[:with_rates]
  yield(self)
ensure
  Thread.current[:with_rates] = with_rates_was
end

Instance Method Details

#drawObject



31
32
# File 'lib/wtf_chord/formatters/base.rb', line 31

def draw
end

#with_rates?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/wtf_chord/formatters/base.rb', line 34

def with_rates?
  !!@with_rates
end