Class: KiTrello::Command
- Inherits:
-
Object
- Object
- KiTrello::Command
- Defined in:
- lib/ki_trello/command.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #boards(options) ⇒ Object
- #card(card_id, board_id) ⇒ Object
- #create_card(json, opts = {}) ⇒ Object
- #get_card(card_id, board_id = nil) ⇒ Object
-
#initialize(output = $stdout, error = $stderr, config = Kiseru::Config[:ki_trello]) ⇒ Command
constructor
A new instance of Command.
- #list_boards(options = {}) ⇒ Object
- #list_lists(board_id) ⇒ Object
- #lists(board_id) ⇒ Object
Constructor Details
#initialize(output = $stdout, error = $stderr, config = Kiseru::Config[:ki_trello]) ⇒ Command
Returns a new instance of Command.
7 8 9 10 11 12 |
# File 'lib/ki_trello/command.rb', line 7 def initialize(output=$stdout, error=$stderr, config = Kiseru::Config[:ki_trello]) @output = output @error = error @config = config @pretty = true end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/ki_trello/command.rb', line 5 def config @config end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/ki_trello/command.rb', line 5 def error @error end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
5 6 7 |
# File 'lib/ki_trello/command.rb', line 5 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
5 6 7 |
# File 'lib/ki_trello/command.rb', line 5 def output @output end |
Instance Method Details
#boards(options) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ki_trello/command.rb', line 51 def boards() session = Session.new(@config) boards = session.boards.map {|b| Board.new(b) } board_data = if [:details] boards.map(&:full) else boards.map(&:simplified) end MultiJson.dump(board_data, :pretty => @pretty) end |
#card(card_id, board_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ki_trello/command.rb', line 34 def card(card_id, board_id) session = Session.new(@config) simple_card_id = extract_id(card_id) card_data = if board_id session.card_on_board(board_id, simple_card_id) else session.card(simple_card_id) end MultiJson.dump(card_data, :pretty => @pretty) end |
#create_card(json, opts = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ki_trello/command.rb', line 22 def create_card(json, opts = {}) list_id = opts.fetch(:list) session = Session.new(@config) data = MultiJson.load(json) card = session.new_card(list_id, data) output.puts(MultiJson.dump(card, :pretty => @pretty)) end |
#get_card(card_id, board_id = nil) ⇒ Object
18 19 20 |
# File 'lib/ki_trello/command.rb', line 18 def get_card(card_id, board_id=nil) output.puts(card(card_id, board_id)) end |
#list_boards(options = {}) ⇒ Object
14 15 16 |
# File 'lib/ki_trello/command.rb', line 14 def list_boards(={}) output.puts(boards()) end |
#list_lists(board_id) ⇒ Object
30 31 32 |
# File 'lib/ki_trello/command.rb', line 30 def list_lists(board_id) output.puts(lists(board_id)) end |