Class: AIX::Errlog::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/aix/errlog/match.rb

Overview

Match convenience function. Gets a Leaf match for comparing against class.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left:, operator: nil, right: nil) ⇒ Match

Returns a new instance of Match.



42
43
44
45
46
# File 'lib/aix/errlog/match.rb', line 42

def initialize(left:, operator: nil, right: nil)
  @left = left
  @operator = operator
  @right = right
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



40
41
42
# File 'lib/aix/errlog/match.rb', line 40

def left
  @left
end

#operatorObject

Returns the value of attribute operator.



40
41
42
# File 'lib/aix/errlog/match.rb', line 40

def operator
  @operator
end

#rightObject

Returns the value of attribute right.



40
41
42
# File 'lib/aix/errlog/match.rb', line 40

def right
  @right
end

Class Method Details

.classObject



193
194
195
# File 'lib/aix/errlog/match.rb', line 193

def self.class
  new(left: :class)
end

.connwhereObject

Match convenience function. Gets a Leaf match for comparing against connwhere.



240
241
242
# File 'lib/aix/errlog/match.rb', line 240

def self.connwhere
  new(left: :connwhere)
end

.crcidObject



175
176
177
# File 'lib/aix/errlog/match.rb', line 175

def self.crcid
  new(left: :crcid)
end

.detail_dataObject

Match convenience function. Gets a Leaf match for comparing against detail_data.



258
259
260
# File 'lib/aix/errlog/match.rb', line 258

def self.detail_data
  new(left: :detail_data)
end

.errdiagObject

Match convenience function. Gets a Leaf match for comparing against errdiag.



270
271
272
# File 'lib/aix/errlog/match.rb', line 270

def self.errdiag
  new(left: :errdiag)
end

.flag_err64Object

Match convenience function. Gets a Leaf match for comparing against flag_err64.



246
247
248
# File 'lib/aix/errlog/match.rb', line 246

def self.flag_err64
  new(left: :flag_err64)
end

.flag_errdupObject

Match convenience function. Gets a Leaf match for comparing against flag_errdup.



252
253
254
# File 'lib/aix/errlog/match.rb', line 252

def self.flag_errdup
  new(left: :flag_errdup)
end

.inObject

Match convenience function. Gets a Leaf match for comparing against in.



234
235
236
# File 'lib/aix/errlog/match.rb', line 234

def self.in
  new(left: :in)
end

.labelObject



163
164
165
# File 'lib/aix/errlog/match.rb', line 163

def self.label
  new(left: :label)
end

.machineidObject



181
182
183
# File 'lib/aix/errlog/match.rb', line 181

def self.machineid
  new(left: :machineid)
end

.nodeidObject



187
188
189
# File 'lib/aix/errlog/match.rb', line 187

def self.nodeid
  new(left: :nodeid)
end

.rclassObject

Match convenience function. Gets a Leaf match for comparing against rclass.



211
212
213
# File 'lib/aix/errlog/match.rb', line 211

def self.rclass
  new(left: :rclass)
end

.resourceObject

Match convenience function. Gets a Leaf match for comparing against resource.



205
206
207
# File 'lib/aix/errlog/match.rb', line 205

def self.resource
  new(left: :resource)
end

.rtypeObject

Match convenience function. Gets a Leaf match for comparing against rtype.



217
218
219
# File 'lib/aix/errlog/match.rb', line 217

def self.rtype
  new(left: :rtype)
end

.sequenceObject



157
158
159
# File 'lib/aix/errlog/match.rb', line 157

def self.sequence
  new(left: :sequence)
end

.symptom_dataObject

Match convenience function. Gets a Leaf match for comparing against symptom_data.



264
265
266
# File 'lib/aix/errlog/match.rb', line 264

def self.symptom_data
  new(left: :symptom_data)
end

.timestampObject



169
170
171
# File 'lib/aix/errlog/match.rb', line 169

def self.timestamp
  new(left: :timestamp)
end

.typeObject

Match convenience function. Gets a Leaf match for comparing against type.



199
200
201
# File 'lib/aix/errlog/match.rb', line 199

def self.type
  new(left: :type)
end

.vpd_ibmObject

Match convenience function. Gets a Leaf match for comparing against vpd_ibm.



223
224
225
# File 'lib/aix/errlog/match.rb', line 223

def self.vpd_ibm
  new(left: :vpd_ibm)
end

.vpd_userObject

Match convenience function. Gets a Leaf match for comparing against vpd_user.



229
230
231
# File 'lib/aix/errlog/match.rb', line 229

def self.vpd_user
  new(left: :vpd_user)
end

.wparidObject

Match convenience function. Gets a Leaf match for comparing against wparid.



276
277
278
# File 'lib/aix/errlog/match.rb', line 276

def self.wparid
  new(left: :wparid)
end

Instance Method Details

#!Object



147
148
149
150
151
152
# File 'lib/aix/errlog/match.rb', line 147

def !
  Match.new(
    left: self,
    operator: :not,
  )
end

#!=(other) ⇒ Object



96
97
98
99
100
# File 'lib/aix/errlog/match.rb', line 96

def !=(other)
  @operator = :ne
  @right = other
  self
end

#&(other) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/aix/errlog/match.rb', line 126

def &(other)
  Match.new(
    left: self,
    operator: :and,
    right: other,
  )
end

#<(other) ⇒ Object



106
107
108
109
110
# File 'lib/aix/errlog/match.rb', line 106

def <(other)
  @operator = :lt
  @right = other
  self
end

#<=(other) ⇒ Object



111
112
113
114
115
# File 'lib/aix/errlog/match.rb', line 111

def <=(other)
  @operator = :le
  @right = other
  self
end

#==(other) ⇒ Object



91
92
93
94
95
# File 'lib/aix/errlog/match.rb', line 91

def ==(other)
  @operator = :equal
  @right = other
  self
end

#>(other) ⇒ Object



116
117
118
119
120
# File 'lib/aix/errlog/match.rb', line 116

def >(other)
  @operator = :gt
  @right = other
  self
end

#>=(other) ⇒ Object



121
122
123
124
125
# File 'lib/aix/errlog/match.rb', line 121

def >=(other)
  @operator = :ge
  @right = other
  self
end

#^(other) ⇒ Object



140
141
142
143
144
145
146
# File 'lib/aix/errlog/match.rb', line 140

def ^(other)
  Match.new(
    left: self,
    operator: :xor,
    right: other,
  )
end

#include?(other) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
104
105
# File 'lib/aix/errlog/match.rb', line 101

def include?(other)
  @operator = :substr
  @right = other
  self
end

#to_structObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/aix/errlog/match.rb', line 56

def to_struct
  raise "operator must be a symbol, but is #{@operator}" unless @operator.is_a? Symbol

  # We want to be sure the struct is not garbage collected before it's
  # used, so we need to retain a reference to it that ensures that it will
  # live as long as this object
  @struct = Lib::ErrlogMatch.new

  @struct[:em_op] = @operator

  case @left
  when Match
    @struct[:emu1][:emu_left] = @left.to_struct
  when Symbol
    @struct[:emu1][:emu_field] = @left
  else
    raise "left should be either a Match or Symbol object, but is #{@left}"
  end

  case @right
  when Match
    @struct[:emu2][:emu_right] = @right.to_struct
  when String
    @struct[:emu2][:emu_strvalue] = @right
  when Numeric, Time
    @struct[:emu2][:emu_intvalue] = @right.to_i
  when DateTime
    @struct[:emu2][:emu_intvalue] = @right.to_time.to_i
  else
    raise "left should be either a Match or Symbol object, but is #{@left}"
  end

  @struct
end

#|(other) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/aix/errlog/match.rb', line 133

def |(other)
  Match.new(
    left: self,
    operator: :or,
    right: other,
  )
end