yinum 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/enum/helpers/enum_column.rb +0 -1
- data/lib/enum.rb +4 -1
- data/spec/lib/enum_spec.rb +9 -0
- data/yinum.gemspec +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/enum.rb
CHANGED
@@ -28,7 +28,10 @@ class Enum
|
|
28
28
|
@by_name.each_value(&block)
|
29
29
|
end
|
30
30
|
|
31
|
-
def [](
|
31
|
+
def [](*name_or_values)
|
32
|
+
return name_or_values.map { |name_or_value| self[name_or_value] } if name_or_values.length > 1
|
33
|
+
|
34
|
+
name_or_value = name_or_values.first
|
32
35
|
ev = @by_name[name_or_value] || @by_value[name_or_value]
|
33
36
|
raise "#{inspect} does not know #{name_or_value.inspect}" if ev.nil?
|
34
37
|
ev
|
data/spec/lib/enum_spec.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Enum do
|
4
|
+
context "accessors" do
|
5
|
+
before { @enum = Enum.new(:MY_COLORS, :red => 1, :blue => 2) }
|
6
|
+
|
7
|
+
specify { @enum.red.should == 1 }
|
8
|
+
specify { @enum[:red].should == 1 }
|
9
|
+
specify { expect { @enum[:black] }.to raise_error(StandardError) }
|
10
|
+
specify { @enum[:red, :blue].should == [1, 2] }
|
11
|
+
end # context "accessors
|
12
|
+
|
4
13
|
context "keys on left and right" do
|
5
14
|
before { @enum = Enum.new(:MY_COLORS, :red => 1, 2 => :blue) }
|
6
15
|
subject { @enum }
|
data/yinum.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Yummy implementation of enum that gives integer values with a special
|
15
15
|
wrapping.
|