protobuf 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,14 @@
1
- require 'delegate'
2
1
  require 'protobuf/enum'
3
2
 
4
3
  module Protobuf
5
- class EnumValue < SimpleDelegator
4
+ class EnumValue
5
+ include Comparable
6
6
 
7
7
  attr_reader :parent_class, :name, :value
8
8
 
9
- # Overriding the class so ActiveRecord/Arel visitor will visit the enum as a Fixnum
10
- def class
11
- Fixnum
12
- end
13
-
9
+ ##
10
+ # Constructor
11
+ #
14
12
  def initialize(parent_class, name, value)
15
13
  @parent_class = parent_class
16
14
  @name = name
@@ -18,6 +16,23 @@ module Protobuf
18
16
  super(@value)
19
17
  end
20
18
 
19
+ ##
20
+ # Public Instance Methods
21
+ #
22
+ def <=>(compared_value)
23
+ case compared_value
24
+ when ::Protobuf::EnumValue then
25
+ value <=> compared_value.value
26
+ when Numeric then
27
+ value <=> compared_value.to_i
28
+ end
29
+ end
30
+
31
+ # Overriding the class so ActiveRecord/Arel visitor will visit the enum as a Fixnum
32
+ def class
33
+ Fixnum
34
+ end
35
+
21
36
  def inspect
22
37
  "\#<Protobuf::EnumValue #{@parent_class}::#{@name}=#{@value}>"
23
38
  end
@@ -26,6 +41,10 @@ module Protobuf
26
41
  self.to_i
27
42
  end
28
43
 
44
+ def to_i
45
+ @value.to_i
46
+ end
47
+
29
48
  def to_s(format = :value_string)
30
49
  case format
31
50
  when :value_string then
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.2.2'
2
+ VERSION = '2.2.3'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe Protobuf::EnumValue do
4
4
 
5
5
  subject { Test::EnumTestType::ONE }
6
- its(:class) { should eq Fixnum }
7
- its(:parent_class) { should eq Test::EnumTestType }
8
- its(:name) { should eq :ONE }
9
- its(:value) { should eq 1 }
10
- its(:to_hash_value) { should eq 1 }
11
- its(:to_s) { should eq "1" }
12
- its(:inspect) { should eq '#<Protobuf::EnumValue Test::EnumTestType::ONE=1>' }
6
+ its(:class) { should eq(Fixnum) }
7
+ its(:parent_class) { should eq(Test::EnumTestType) }
8
+ its(:name) { should eq(:ONE) }
9
+ its(:value) { should eq(1) }
10
+ its(:to_hash_value) { should eq(1) }
11
+ its(:to_s) { should eq("1") }
12
+ its(:inspect) { should eq('#<Protobuf::EnumValue Test::EnumTestType::ONE=1>') }
13
13
  specify { subject.to_s(:name).should eq("ONE") }
14
14
 
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-12 00:00:00.000000000 Z
13
+ date: 2012-11-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -485,7 +485,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
485
485
  version: '0'
486
486
  segments:
487
487
  - 0
488
- hash: 659886342819533463
488
+ hash: 878827377950165717
489
489
  required_rubygems_version: !ruby/object:Gem::Requirement
490
490
  none: false
491
491
  requirements:
@@ -494,7 +494,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
494
494
  version: '0'
495
495
  segments:
496
496
  - 0
497
- hash: 659886342819533463
497
+ hash: 878827377950165717
498
498
  requirements: []
499
499
  rubyforge_project:
500
500
  rubygems_version: 1.8.24