Class: Frag::State

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(beginning, ending, leader, trailer, backup_prefix, backup_suffix) ⇒ State

Returns a new instance of State.



190
191
192
193
194
195
196
197
# File 'lib/frag/app.rb', line 190

def initialize(beginning, ending, leader, trailer, backup_prefix, backup_suffix)
  @beginning = beginning
  @ending = ending
  @leader = leader
  @trailer = trailer
  @backup_prefix = backup_prefix
  @backup_suffix = backup_suffix
end

Instance Attribute Details

#backup_prefixObject

Returns the value of attribute backup_prefix.



199
200
201
# File 'lib/frag/app.rb', line 199

def backup_prefix
  @backup_prefix
end

#backup_suffixObject

Returns the value of attribute backup_suffix.



199
200
201
# File 'lib/frag/app.rb', line 199

def backup_suffix
  @backup_suffix
end

#beginningObject

Returns the value of attribute beginning.



199
200
201
# File 'lib/frag/app.rb', line 199

def beginning
  @beginning
end

#endingObject

Returns the value of attribute ending.



199
200
201
# File 'lib/frag/app.rb', line 199

def ending
  @ending
end

#leaderObject

Returns the value of attribute leader.



199
200
201
# File 'lib/frag/app.rb', line 199

def leader
  @leader
end

#trailerObject

Returns the value of attribute trailer.



199
200
201
# File 'lib/frag/app.rb', line 199

def trailer
  @trailer
end

Instance Method Details

#begin_lineObject



223
224
225
# File 'lib/frag/app.rb', line 223

def begin_line
  @begin_line ||= build_begin_line
end

#build_begin_lineObject



231
232
233
234
235
236
# File 'lib/frag/app.rb', line 231

def build_begin_line
  leader = Regexp.escape(@leader)
  beginning = Regexp.escape(@beginning)
  trailer = Regexp.escape(@trailer)
  @begin_line = Regexp.new(['^', leader, beginning, '(.*)', trailer, '$'].reject(&:empty?).join('\\s*'))
end

#build_end_lineObject



238
239
240
241
242
243
# File 'lib/frag/app.rb', line 238

def build_end_line
  leader = Regexp.escape(@leader)
  ending = Regexp.escape(@ending)
  trailer = Regexp.escape(@trailer)
  @end_line = Regexp.new(['^', leader, ending, trailer, '$'].reject(&:empty?).join('\\s*'))
end

#end_lineObject



227
228
229
# File 'lib/frag/app.rb', line 227

def end_line
  @end_line ||= build_end_line
end