Class: Unparser::Writer::Binary

Inherits:
Object
  • Object
show all
Includes:
Adamantium, Unparser::Writer
Defined in:
lib/unparser/writer/binary.rb

Constant Summary collapse

OPERATOR_TOKENS =
{
  and: '&&',
  or:  '||'
}.freeze
KEYWORD_TOKENS =
{
  and: 'and',
  or:  'or'
}.freeze
KEYWORD_SYMBOLS =
{
  and: :kAND,
  or:  :kOR
}.freeze
OPERATOR_SYMBOLS =
{
  and: :tANDOP,
  or:  :tOROP
}.freeze
MAP =
{
  kAND:   'and',
  kOR:    'or',
  tOROP:  '||',
  tANDOP: '&&'
}.freeze
NEED_KEYWORD =
%i[return break next].freeze

Constants included from Generation

Generation::EXTRA_NL

Instance Method Summary collapse

Methods included from Unparser::Writer

included

Methods included from Generation

#emit_heredoc_reminders, #write_to_buffer

Methods included from NodeHelpers

#n, #n?, #s, #unwrap_single_begin

Instance Method Details

#dispatchObject



54
55
56
57
58
# File 'lib/unparser/writer/binary.rb', line 54

def dispatch
  left_emitter.write_to_buffer
  write(' ', MAP.fetch(effective_symbol), ' ')
  visit(right)
end

#emit_operatorObject



46
47
48
# File 'lib/unparser/writer/binary.rb', line 46

def emit_operator
  emit_with(OPERATOR_TOKENS)
end

#symbol_nameObject



50
51
52
# File 'lib/unparser/writer/binary.rb', line 50

def symbol_name
  true
end