This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix special char conflict with regexp & refactoring
- Loading branch information
Showing
11 changed files
with
93 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
# Copyright (C) 2011 Kenichi Kamiya | ||
# Copyright (C) 2011 Kenichi Kamiya | ||
|
||
class Integer | ||
|
||
module Base | ||
|
||
class InvalidCharacter < TypeError; end | ||
class InvalidCharacterError < TypeError; end | ||
|
||
SPECIAL_CHAR_PATTERN = /[\x00-\x20\-\+]/ | ||
|
||
# @return [Hash] | ||
# @example | ||
# { 1 => [:"0"], | ||
# 2 => [:"0", :"1"], | ||
# 36 => [:"0", :"1", ... , :Z] } | ||
STANDARD_CHARS = Hash.new{|*|raise KeyError}.tap {|standards| | ||
1.upto 10 do |n| | ||
standards[n] = ('0'..((n - 1).to_s)).map(&:to_sym).freeze | ||
end | ||
|
||
alphabets = ('A'..'Z').map(&:to_sym) | ||
|
||
11.upto 36 do |n| | ||
standards[n] = [ | ||
*standards[10], *alphabets.slice(0, n - 10) | ||
].freeze | ||
end | ||
|
||
standards[:BINARY] = standards[2] | ||
}.freeze | ||
|
||
end | ||
|
||
end | ||
|
||
require_relative 'base/version' | ||
require_relative 'base/singletonclass' | ||
require_relative 'base/standard_chars' | ||
require_relative 'base/requirements' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require_relative 'singleton_class' | ||
require_relative 'version' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class Integer; module Base | ||
|
||
VERSION = '0.0.5'.freeze | ||
VERSION = '0.0.6'.freeze | ||
|
||
end; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'test/unit' | ||
|
||
$VERBOSE = true | ||
|
||
require_relative '../lib/integer/base/core_ext' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters