Class: Ruby::Node::Text::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/node/text.rb

Constant Summary collapse

@@context_width =
2

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lines, row, width = nil, line = nil) ⇒ Context

Returns a new instance of Context.



27
28
29
30
31
32
# File 'lib/ruby/node/text.rb', line 27

def initialize(lines, row, width = nil, line = nil)
  @lines = lines
  @line = line || lines[row]
  @row = row
  @width = width || Context.width
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



25
26
27
# File 'lib/ruby/node/text.rb', line 25

def line
  @line
end

#linesObject (readonly)

Returns the value of attribute lines.



25
26
27
# File 'lib/ruby/node/text.rb', line 25

def lines
  @lines
end

#rowObject (readonly)

Returns the value of attribute row.



25
26
27
# File 'lib/ruby/node/text.rb', line 25

def row
  @row
end

#widthObject (readonly)

Returns the value of attribute width.



25
26
27
# File 'lib/ruby/node/text.rb', line 25

def width
  @width
end

Class Method Details

.context_widthObject



16
17
18
# File 'lib/ruby/node/text.rb', line 16

def context_width
  @@context_width
end

.context_width=(context_width) ⇒ Object



20
21
22
# File 'lib/ruby/node/text.rb', line 20

def context_width=(context_width)
  @@context_width = context_width
end

Instance Method Details

#to_s(options = {}) ⇒ Object



34
35
36
# File 'lib/ruby/node/text.rb', line 34

def to_s(options = {})
  (head + [line] + tail).join("\n")
end