Class: Mingle::CardType

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

Overview

This is a lightweight representation of a card type in Mingle. From an instance of this class you can the name, color and position of the card type, in addition to Property Definitions that are associated with it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_card_type) ⇒ CardType

Returns a new instance of CardType.



9
10
11
# File 'lib/mingle_macro_models/card_type.rb', line 9

def initialize(full_card_type)
  @full_card_type = full_card_type
end

Instance Attribute Details

#card_types_property_definitions_loader=(value) ⇒ Object (writeonly)

Sets the attribute card_types_property_definitions_loader

Parameters:

  • value

    the value to set the attribute card_types_property_definitions_loader to.



38
39
40
# File 'lib/mingle_macro_models/card_type.rb', line 38

def card_types_property_definitions_loader=(value)
  @card_types_property_definitions_loader = value
end

Instance Method Details

#colorObject

returns: The hex color code for this CardType



19
20
21
# File 'lib/mingle_macro_models/card_type.rb', line 19

def color
  @full_card_type.color.gsub('#', '')
end

#nameObject

returns: The name of this CardType



14
15
16
# File 'lib/mingle_macro_models/card_type.rb', line 14

def name
  @full_card_type.name
end

#positionObject

returns: The position of this CardType among all the CardTypes on the project. The first card type has position 1



25
26
27
# File 'lib/mingle_macro_models/card_type.rb', line 25

def position
  @full_card_type.position
end

#property_definitionsObject

returns: The PropertyDefinitions associated with this CardType



30
31
32
# File 'lib/mingle_macro_models/card_type.rb', line 30

def property_definitions
  @card_types_property_definitions_loader.load.collect(&:property_definition)
end

#to_sObject



34
35
36
# File 'lib/mingle_macro_models/card_type.rb', line 34

def to_s
  "CardType[name=#{name},color=#{color},position=#{position}]"
end