Class: StackDeck::Context
- Inherits:
-
Object
- Object
- StackDeck::Context
- Defined in:
- lib/stackdeck/context.rb,
lib/stackdeck/postgres.rb
Defined Under Namespace
Constant Summary collapse
- CONTEXT =
7
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
Returns the value of attribute after.
-
#before ⇒ Object
readonly
Returns the value of attribute before.
-
#before_lineno ⇒ Object
readonly
Returns the value of attribute before_lineno.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #context_ranges(lines, index) ⇒ Object
-
#initialize(lines, lineno) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(lines, lineno) ⇒ Context
Returns a new instance of Context.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/stackdeck/context.rb', line 12 def initialize(lines, lineno) if lineno index = lineno - 1 pre_range, post_range = context_ranges(lines, index) @before_lineno = pre_range.begin @before = lines[pre_range] @line = lines[index] @after = lines[post_range] else @line = lines.join("\n") end end |
Instance Attribute Details
#after ⇒ Object (readonly)
Returns the value of attribute after.
5 6 7 |
# File 'lib/stackdeck/context.rb', line 5 def after @after end |
#before ⇒ Object (readonly)
Returns the value of attribute before.
5 6 7 |
# File 'lib/stackdeck/context.rb', line 5 def before @before end |
#before_lineno ⇒ Object (readonly)
Returns the value of attribute before_lineno.
5 6 7 |
# File 'lib/stackdeck/context.rb', line 5 def before_lineno @before_lineno end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/stackdeck/context.rb', line 5 def line @line end |