Class: EacRubyUtils::StringDelimited

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/string_delimited.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, begin_delimiter, end_delimiter) ⇒ StringDelimited

Returns a new instance of StringDelimited.



7
8
9
10
11
# File 'lib/eac_ruby_utils/string_delimited.rb', line 7

def initialize(string, begin_delimiter, end_delimiter)
  @string = string
  @begin_delimiter = begin_delimiter
  @end_delimiter = end_delimiter
end

Instance Attribute Details

#begin_delimiterObject (readonly)

Returns the value of attribute begin_delimiter.



5
6
7
# File 'lib/eac_ruby_utils/string_delimited.rb', line 5

def begin_delimiter
  @begin_delimiter
end

#end_delimiterObject (readonly)

Returns the value of attribute end_delimiter.



5
6
7
# File 'lib/eac_ruby_utils/string_delimited.rb', line 5

def end_delimiter
  @end_delimiter
end

#stringObject (readonly)

Returns the value of attribute string.



5
6
7
# File 'lib/eac_ruby_utils/string_delimited.rb', line 5

def string
  @string
end

Instance Method Details

#innerObject



13
14
15
# File 'lib/eac_ruby_utils/string_delimited.rb', line 13

def inner
  between_indexes(content_index, end_index).to_s
end

#outerObject



17
18
19
# File 'lib/eac_ruby_utils/string_delimited.rb', line 17

def outer
  between_indexes(begin_index, after_end_index).to_s
end

#without_innerObject



21
22
23
24
25
# File 'lib/eac_ruby_utils/string_delimited.rb', line 21

def without_inner
  without_join(
    between_indexes(sos_index, content_index), between_indexes(end_index, eos_index)
  )
end

#without_outerObject



27
28
29
30
31
32
# File 'lib/eac_ruby_utils/string_delimited.rb', line 27

def without_outer
  without_join(
    between_indexes(sos_index, begin_index),
    between_indexes(after_end_index, eos_index)
  )
end