Class: ReVIEW::Preprocessor::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/review/preprocessor/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, string) ⇒ Line

Returns a new instance of Line.



12
13
14
15
# File 'lib/review/preprocessor/line.rb', line 12

def initialize(number, string)
  @number = number
  @string = string
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



17
18
19
# File 'lib/review/preprocessor/line.rb', line 17

def number
  @number
end

#stringObject (readonly) Also known as: to_s

Returns the value of attribute string.



18
19
20
# File 'lib/review/preprocessor/line.rb', line 18

def string
  @string
end

Instance Method Details

#editObject



21
22
23
# File 'lib/review/preprocessor/line.rb', line 21

def edit
  self.class.new(@number, yield(@string))
end

#empty?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/review/preprocessor/line.rb', line 25

def empty?
  @string.strip.empty?
end

#num_indentObject



29
30
31
# File 'lib/review/preprocessor/line.rb', line 29

def num_indent
  @string.slice(/\A\s*/).size
end