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.



182
183
184
185
186
187
188
189
# File 'lib/frag/app.rb', line 182

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.



191
192
193
# File 'lib/frag/app.rb', line 191

def backup_prefix
  @backup_prefix
end

#backup_suffixObject

Returns the value of attribute backup_suffix.



191
192
193
# File 'lib/frag/app.rb', line 191

def backup_suffix
  @backup_suffix
end

#beginningObject

Returns the value of attribute beginning.



191
192
193
# File 'lib/frag/app.rb', line 191

def beginning
  @beginning
end

#endingObject

Returns the value of attribute ending.



191
192
193
# File 'lib/frag/app.rb', line 191

def ending
  @ending
end

#leaderObject

Returns the value of attribute leader.



191
192
193
# File 'lib/frag/app.rb', line 191

def leader
  @leader
end

#trailerObject

Returns the value of attribute trailer.



191
192
193
# File 'lib/frag/app.rb', line 191

def trailer
  @trailer
end

Instance Method Details

#begin_lineObject



215
216
217
# File 'lib/frag/app.rb', line 215

def begin_line
  @begin_line ||= build_begin_line
end

#build_begin_lineObject



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

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



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

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



219
220
221
# File 'lib/frag/app.rb', line 219

def end_line
  @end_line ||= build_end_line
end