Class: Giter8::Literal

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/giter8/literal.rb

Overview

Literal represents a sequence of one or more characters not separated by either a Template or Condition node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, parent, source, line, column) ⇒ Literal

Returns a new instance of Literal.



10
11
12
13
14
15
16
# File 'lib/giter8/literal.rb', line 10

def initialize(value, parent, source, line, column)
  @source = source
  @line = line
  @column = column
  @value = value
  @parent = parent
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



8
9
10
# File 'lib/giter8/literal.rb', line 8

def column
  @column
end

#lineObject

Returns the value of attribute line.



8
9
10
# File 'lib/giter8/literal.rb', line 8

def line
  @line
end

#parentObject

Returns the value of attribute parent.



8
9
10
# File 'lib/giter8/literal.rb', line 8

def parent
  @parent
end

#sourceObject

Returns the value of attribute source.



8
9
10
# File 'lib/giter8/literal.rb', line 8

def source
  @source
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/giter8/literal.rb', line 8

def value
  @value
end

Instance Method Details

#inspectObject



26
27
28
29
30
31
32
33
34
# File 'lib/giter8/literal.rb', line 26

def inspect
  parent = @parent
  parent = if parent.nil?
             "nil"
           else
             "#<#{@parent.class.name}:#{format("%08x", (@parent.object_id * 2))}>"
           end
  "#<#{self.class.name}:#{format("%08x", (object_id * 2))} line=#{@line} value=#{@value.inspect} parent=#{parent}>"
end

#linebreak?Boolean

Returns whether this node’s value is comprised solely of a linebreak

Returns:

  • (Boolean)


22
23
24
# File 'lib/giter8/literal.rb', line 22

def linebreak?
  ["\r\n", "\n"].include? @value
end