Class: ONIX::SubsetArray

Inherits:
Array
  • Object
show all
Defined in:
lib/onix/subset.rb

Instance Method Summary collapse

Instance Method Details

#code_match(k, p) ⇒ SubsetArray

Parameters:

  • k (Symbol)
  • p (String)

Returns:



258
259
260
261
262
263
264
265
266
267
268
# File 'lib/onix/subset.rb', line 258

def code_match(k, p)
  case p
  when Regexp
    self.class.new(self.select { |v|
      code = v.instance_variable_get("@" + k.to_s)
      code.code =~ p
    })
  else
    self.class.new(self.select { |v| v.instance_variable_get("@" + k.to_s).code == p })
  end
end

#human_code_match(k, p) ⇒ SubsetArray

Parameters:

  • k (Symbol)
  • p (String)

Returns:



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/onix/subset.rb', line 235

def human_code_match(k, p)
  case p
  when Regexp
    self.class.new(self.select { |v|
      code = v.instance_variable_get("@" + k.to_s)
      code and code.human =~ p
    })
  when Array
    self.class.new(self.select { |v|
      code = v.instance_variable_get("@" + k.to_s)
      code and p.include?(code.human)
    })
  else
    self.class.new(self.select { |v|
      code = v.instance_variable_get("@" + k.to_s)
      code and code.human == p
    })
  end
end