Sha256: 03b97d445e06bb830403d17c677fa569ad01595444f32e31595182bb67523c02

Contents?: true

Size: 428 Bytes

Versions: 89

Compression:

Stored size: 428 Bytes

Contents

# encoding: utf-8

# String
class String
  # hyphen-format string to array.
  #
  # ==== Examples
  #
  # number case
  #
  #   '1-5'.hyphen_to_a # => [1, 2, 3, 4, 5]
  #
  # alphabet case
  #
  #   '"a"-"e"'.hyphen_to_a # => ['a', 'b', 'c', 'd', 'e']
  #
  def hyphen_to_a
    return self unless self.include? '-'
    return self unless count('-') == 1
    eval "[*#{gsub('-', '..')}]", binding
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.91 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.90 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.89 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.88 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.87 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.86 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.85 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.84 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.83 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.82 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.81 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.80 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.79 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.78 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.77 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.76 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.75 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.74 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.73 lib/open_classes/string/hyphen_to_a.rb
tbpgr_utils-0.0.72 lib/open_classes/string/hyphen_to_a.rb