Class: Pal

Inherits:
Object
  • Object
show all
Defined in:
lib/sw_info.rb

Direct Known Subclasses

Person, Starship, Vehicle

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Pal

Returns a new instance of Pal.



48
49
50
# File 'lib/sw_info.rb', line 48

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



21
22
23
# File 'lib/sw_info.rb', line 21

def data
  @data
end

Class Method Details

.allObject



37
# File 'lib/sw_info.rb', line 37

def self.all; end

.find(id) ⇒ Object



35
# File 'lib/sw_info.rb', line 35

def self.find(id); end

.search_for_all(key) ⇒ Object



39
40
41
# File 'lib/sw_info.rb', line 39

def self.search_for_all(key)
  DATA[key].map { |j| new(j) }
end

.search_for_id(key, id) ⇒ Object



43
44
45
46
# File 'lib/sw_info.rb', line 43

def self.search_for_id(key, id)
  variable = DATA[key].find { |j| j['id'] == id }
  new(variable)
end

Instance Method Details

#idObject



27
28
29
# File 'lib/sw_info.rb', line 27

def id
  @data['id']
end

#nameObject



31
32
33
# File 'lib/sw_info.rb', line 31

def name
  @data['name']
end

#to_sObject



23
24
25
# File 'lib/sw_info.rb', line 23

def to_s
  @data.to_s
end