Class: SyntaxTree::HshPtn::KeywordFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ KeywordFormatter

Returns a new instance of KeywordFormatter.



6217
6218
6219
6220
# File 'lib/syntax_tree.rb', line 6217

def initialize(key, value)
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject (readonly)

Label

the keyword being used



6212
6213
6214
# File 'lib/syntax_tree.rb', line 6212

def key
  @key
end

#valueObject (readonly)

untyped

the optional value for the keyword



6215
6216
6217
# File 'lib/syntax_tree.rb', line 6215

def value
  @value
end

Instance Method Details

#commentsObject



6222
6223
6224
# File 'lib/syntax_tree.rb', line 6222

def comments
  []
end

#format(q) ⇒ Object



6226
6227
6228
6229
6230
6231
6232
6233
# File 'lib/syntax_tree.rb', line 6226

def format(q)
  q.format(key)

  if value
    q.text(" ")
    q.format(value)
  end
end