Class: FlagSetMaker::Flags

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/flag_set_maker.rb

Instance Method Summary collapse

Constructor Details

#initialize(v, fs) ⇒ Flags

Returns a new instance of Flags.



46
47
48
49
# File 'lib/flag_set_maker.rb', line 46

def initialize(v, fs)
  @value= fs.validate(v)
  @flag_set= fs
end

Instance Method Details

#&(rhs) ⇒ Object



71
72
73
# File 'lib/flag_set_maker.rb', line 71

def &(rhs)
  return new_flag(@value&rhs.to_i())
end

#==(rhs) ⇒ Object Also known as: eql?



63
64
65
# File 'lib/flag_set_maker.rb', line 63

def ==(rhs)
  return rhs.is_a?(Flags) && @flag_set==rhs.flag_set && @value==rhs.to_i()
end

#empty?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/flag_set_maker.rb', line 87

def empty?()
  return @value!=0
end

#include?(flags) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/flag_set_maker.rb', line 83

def include?(flags)
  return (@value&flags.to_i())==flags.to_i()
end

#inspectObject



59
60
61
# File 'lib/flag_set_maker.rb', line 59

def inspect()
  return @flag_set.inspect(@value)
end

#to_iObject



51
52
53
# File 'lib/flag_set_maker.rb', line 51

def to_i()
  return @value
end

#to_sObject



55
56
57
# File 'lib/flag_set_maker.rb', line 55

def to_s()
  return @flag_set.to_s(@value)
end

#|(rhs) ⇒ Object



75
76
77
# File 'lib/flag_set_maker.rb', line 75

def |(rhs)
  return new_flag(@value|rhs.to_i())
end

#~Object



79
80
81
# File 'lib/flag_set_maker.rb', line 79

def ~()
  return new_flag(~@value)
end