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) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
# File 'lib/onix/subset.rb', line 190

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) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/onix/subset.rb', line 170

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