Class: ManaType

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

Direct Known Subclasses

Black, Blue, Green, Red, White

Defined Under Namespace

Classes: Black, Blue, Green, Red, White

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color, land_type) ⇒ ManaType

Returns a new instance of ManaType.



4
5
6
7
# File 'lib/manasimu/mana_type.rb', line 4

def initialize(color, land_type)
  @land_type = land_type
  @color = color
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



2
3
4
# File 'lib/manasimu/mana_type.rb', line 2

def color
  @color
end

#land_typeObject

Returns the value of attribute land_type.



2
3
4
# File 'lib/manasimu/mana_type.rb', line 2

def land_type
  @land_type
end

Class Method Details

.allObject



9
10
11
12
13
14
15
16
# File 'lib/manasimu/mana_type.rb', line 9

def self.all
  r ||= Red.new
  u ||= Blue.new
  g ||= Green.new
  w ||= White.new
  b ||= Black.new
  @@all ||= [r, u, g, w, b]
end

.search_text_by_color(text) ⇒ Object



24
25
26
27
28
# File 'lib/manasimu/mana_type.rb', line 24

def self.search_text_by_color(text)
  self.all.select do |mana_type|
    text.include? mana_type.color
  end
end

.search_text_by_land_type(text) ⇒ Object



18
19
20
21
22
# File 'lib/manasimu/mana_type.rb', line 18

def self.search_text_by_land_type(text)
  self.all.select do |mana_type|
    text.include? mana_type.land_type
  end
end