Class: Wurfl::Command::Inspector::WurflInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/wurfl/command/inspector.rb

Overview

A class that lists wurfl handsets that match user specified search

criteria.

Instance Method Summary collapse

Constructor Details

#initialize(handsets) ⇒ WurflInspector

Constructor Parameters: handsets: A hashtable of wurfl handsets indexed by wurfl_id.



17
18
19
# File 'lib/wurfl/command/inspector.rb', line 17

def initialize(handsets)
  @handsets = handsets
end

Instance Method Details

#get_handset(id) ⇒ Object

A method to get the WurflHandset that matches the passed wurfl_id. Parameters: id: is the wurfl_id of the WurflHandset to get. Returns: The WurflHandset that has the requested wurfl_id. If the wurfl_id is not found, then nil is returned.



27
28
29
# File 'lib/wurfl/command/inspector.rb', line 27

def get_handset(id)
  return @handsets[id]
end

#search_handsets(proc) ⇒ Object

A method to retrieve a list of the inspector’s handsets that match the passed search criteria. Parameters: proc: is a Proc object that defines a function that returns true or false from an evaluattion with a WurflHandset. Returns: An Array of all WurflHandsets that match the proc evaluation.



38
39
40
41
42
43
44
# File 'lib/wurfl/command/inspector.rb', line 38

def search_handsets(proc)
  rez = @handsets.values.select do |hand|  
    x = proc.call(hand)       
  end
  return rez if rez != nil
  return Array::new
end