hash-utils 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/hash-utils.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hash-utils}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Kozák"]
@@ -70,33 +70,33 @@ class String
70
70
  # @since 0.4.0
71
71
  #
72
72
 
73
- def tr(defs, mode = nil, &block)
73
+ def strtr(defs, mode = nil, &block)
74
74
  if block.nil?
75
75
  block = Proc::new { |s| s }
76
76
  end
77
77
 
78
- defs, matcher = __prepare_tr(defs, mode)
78
+ defs, matcher = __prepare_strtr(defs, mode)
79
79
  self.gsub(matcher) { |s| defs[block.call(s)] }
80
80
  end
81
81
 
82
82
  ##
83
83
  # Replaces set of substrings by another strings -- in place.
84
- # See {#tr} for details.
84
+ # See {#strtr} for details.
85
85
  #
86
86
  # @param [Array, Hash] replacements replacements definition
87
87
  # @param [Symbol] mode flat mode switch, can be +:flat+ or +nil+
88
88
  # @param [Proc] block with keys mapping worker (see description)
89
89
  # @return [String] string with applied replacements
90
- # @see #tr
90
+ # @see #strtr
91
91
  # @since 0.4.0
92
92
  #
93
93
 
94
- def tr!(defs, mode = nil, &block)
94
+ def strtr!(defs, mode = nil, &block)
95
95
  if block.nil?
96
96
  block = Proc::new { |s| s }
97
97
  end
98
98
 
99
- defs, matcher = __prepare_tr(defs, mode)
99
+ defs, matcher = __prepare_strtr(defs, mode)
100
100
  self.gsub!(matcher) { |s| defs[block.call(s)] }
101
101
  end
102
102
 
@@ -104,10 +104,10 @@ class String
104
104
  private
105
105
 
106
106
  ##
107
- # Prepares matcher for #tr.
107
+ # Prepares matcher for #strtr.
108
108
  #
109
109
 
110
- def __prepare_tr(defs, mode = nil)
110
+ def __prepare_strtr(defs, mode = nil)
111
111
  defs = defs.to_h(mode)
112
112
  keys = defs.keys
113
113
  keys.map! { |i| i.to_s }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Martin Koz\xC3\xA1k"
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- hash: -2173078949631025708
88
+ hash: 1545650960635711712
89
89
  segments:
90
90
  - 0
91
91
  version: "0"