Class: Ctrl::Card
- Inherits:
-
Object
- Object
- Ctrl::Card
- Defined in:
- lib/ctrl/card.rb
Instance Attribute Summary collapse
-
#closed ⇒ Object
Returns the value of attribute closed.
-
#description ⇒ Object
Returns the value of attribute description.
-
#due ⇒ Object
Returns the value of attribute due.
-
#id ⇒ Object
Returns the value of attribute id.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#name ⇒ Object
Returns the value of attribute name.
-
#position ⇒ Object
Returns the value of attribute position.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .create(opts) ⇒ Object
- .find_all_by_board(board_id) ⇒ Object
- .find_all_by_list(list_id) ⇒ Object
- .find_by_id(id) ⇒ Object
- .find_by_name(name, obj) ⇒ Object
- .find_by_position(pos, list) ⇒ Object
Instance Method Summary collapse
- #board ⇒ Object
-
#initialize(opts) ⇒ Card
constructor
A new instance of Card.
- #list ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(opts) ⇒ Card
Returns a new instance of Card.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ctrl/card.rb', line 5 def initialize(opts) @id = opts["id"] @name = opts["name"] @description = opts["description"] @due = opts["due"] @labels = opts["labels"] @position = opts["pos"] @closed = opts["closed"] @url = opts["shortUrl"] || opts["url"] @board = Board.new(opts["board"]) if opts["board"] @list = List.new(opts["list"]) if opts["list"] @board_id = opts["idBoard"] @list_id = opts["idList"] end |
Instance Attribute Details
#closed ⇒ Object
Returns the value of attribute closed.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def closed @closed end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def description @description end |
#due ⇒ Object
Returns the value of attribute due.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def due @due end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def id @id end |
#labels ⇒ Object
Returns the value of attribute labels.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def labels @labels end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def name @name end |
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def position @position end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/ctrl/card.rb', line 3 def url @url end |
Class Method Details
.create(opts) ⇒ Object
22 |
# File 'lib/ctrl/card.rb', line 22 def self.create(opts); end |
.find_all_by_board(board_id) ⇒ Object
54 55 56 |
# File 'lib/ctrl/card.rb', line 54 def self.find_all_by_board(board_id) API.get_cards_for_board(board_id).map { |card| Card.new(card) } end |
.find_all_by_list(list_id) ⇒ Object
50 51 52 |
# File 'lib/ctrl/card.rb', line 50 def self.find_all_by_list(list_id); API.get_cards_for_list(list_id).map { |card| Card.new(card) } end |
.find_by_id(id) ⇒ Object
24 25 26 |
# File 'lib/ctrl/card.rb', line 24 def self.find_by_id(id) Card.new(API.get_card(id)) end |
.find_by_name(name, obj) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ctrl/card.rb', line 28 def self.find_by_name(name, obj) if obj.is_a? List fuzzy = FuzzyMatch.new(find_all_by_list(obj.id), read: :name) elsif obj.is_a? Board fuzzy = FuzzyMatch.new(find_all_by_board(obj.id), read: :name) else fail "Object must be a card or a board" end fuzzy.find(name) end |
.find_by_position(pos, list) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ctrl/card.rb', line 39 def self.find_by_position(pos, list) pos = 0 if pos == "first" || pos == "top" pos = -1 if pos == "last" || pos == "bottom" unless pos.is_a? Integer fail "Position must by integer, 'top', 'first', 'bottom', or 'last'" end find_all_by_list(list.id).sort_by(&:position)[pos] end |
Instance Method Details
#board ⇒ Object
58 59 60 |
# File 'lib/ctrl/card.rb', line 58 def board @board ||= Board.find_by_id(@board_id) end |
#list ⇒ Object
62 63 64 |
# File 'lib/ctrl/card.rb', line 62 def list @list ||= List.find_by_id(@list_id) end |
#save ⇒ Object
20 |
# File 'lib/ctrl/card.rb', line 20 def save; end |