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.



28
29
30
31
# File 'lib/wtf_chord/formatters/base.rb', line 28

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

Class Method Details

.separatorObject



13
14
15
# File 'lib/wtf_chord/formatters/base.rb', line 13

def self.separator
  "\n"
end

.to_procObject



17
18
19
# File 'lib/wtf_chord/formatters/base.rb', line 17

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

.with_rates(value = false) ⇒ Object



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

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

#actual_stringsObject



36
37
38
# File 'lib/wtf_chord/formatters/base.rb', line 36

def actual_strings
  strings.reject(&:dead?)
end

#drawObject



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

def draw
end

#with_rates?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/wtf_chord/formatters/base.rb', line 40

def with_rates?
  !!@with_rates
end