Class: Janko::Flag

Inherits:
Object
  • Object
show all
Defined in:
lib/janko/flag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Flag

Returns a new instance of Flag.



5
6
7
# File 'lib/janko/flag.rb', line 5

def initialize(value)
    @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/janko/flag.rb', line 3

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/janko/flag.rb', line 18

def ==(other)
    eql?(other)
end

#===(other) ⇒ Object



22
23
24
# File 'lib/janko/flag.rb', line 22

def ===(other)
    eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/janko/flag.rb', line 13

def eql?(other)
    return unless other.is_a?(self.class)
    (value & other.value) != 0
end

#|(other) ⇒ Object



9
10
11
# File 'lib/janko/flag.rb', line 9

def |(other)
    self.class.new(value | other.value)
end