Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/zaphire.rb
Overview
Extending Ruby !!
Instance Method Summary collapse
- #char(number = 1, number2 = '') ⇒ Object
- #contains(tofind) ⇒ Object
- #delete_char(number = 1, number2 = '') ⇒ Object
- #delete_lines(num_of_lines = 1) ⇒ Object
- #lastchar(a = 1) ⇒ Object
- #line(number = 1, number2 = '') ⇒ Object
- #number_of_lines ⇒ Object
- #ok ⇒ Object
Instance Method Details
#char(number = 1, number2 = '') ⇒ Object
248 249 250 251 252 253 254 255 |
# File 'lib/zaphire.rb', line 248 def char(number = 1, number2 = '') return '' if self == '' if number2 == '' self[number - 1] else self[number - 1..number2 - 1] end end |
#contains(tofind) ⇒ Object
266 267 268 269 |
# File 'lib/zaphire.rb', line 266 def contains(tofind) return false if self == '' self.include? tofind end |
#delete_char(number = 1, number2 = '') ⇒ Object
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/zaphire.rb', line 237 def delete_char(number = 1, number2 = '') return '' if self == '' if number2 == '' self[number - 1] = '' self else self[number - 1..number2 - 1] = '' self end end |
#delete_lines(num_of_lines = 1) ⇒ Object
232 233 234 235 |
# File 'lib/zaphire.rb', line 232 def delete_lines(num_of_lines = 1) return '' if self == '' split(/\r\n|\r|\n/, num_of_lines + 1).last end |
#lastchar(a = 1) ⇒ Object
271 272 273 274 |
# File 'lib/zaphire.rb', line 271 def lastchar(a = 1) return '' if self == '' self[-a..-1] end |
#line(number = 1, number2 = '') ⇒ Object
257 258 259 260 261 262 263 264 |
# File 'lib/zaphire.rb', line 257 def line(number = 1, number2 = '') return '' if self == '' if number2 == '' ok.split("\n")[number - 1] else ok.split("\n")[number - 1..number2 - 1] end end |
#number_of_lines ⇒ Object
276 277 278 279 |
# File 'lib/zaphire.rb', line 276 def number_of_lines return 0 if self == '' lines.count end |
#ok ⇒ Object
281 282 283 |
# File 'lib/zaphire.rb', line 281 def ok force_encoding('UTF-8') end |