Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/hellobase/core_ext/string_access.rb

Instance Method Summary collapse

Instance Method Details

#hb_char(hb_index) ⇒ Object

Raises:



2
3
4
5
6
# File 'lib/hellobase/core_ext/string_access.rb', line 2

def hb_char(hb_index)
  raise Hellobase::Error.new(:string_index, self, hb_index) unless index = hb_convert_index(hb_index)

  self[index]
end

#hb_char_range(hb_start_index, hb_end_index) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/hellobase/core_ext/string_access.rb', line 8

def hb_char_range(hb_start_index, hb_end_index)
  unless (start_index = hb_convert_index(hb_start_index)) && (end_index = hb_convert_index(hb_end_index)) && (end_index >= start_index)
    raise Hellobase::Error.new(:string_index, self, hb_start_index, hb_end_index)
  end

  self[start_index..end_index]
end