class TrelloDXY::Formatters::BoardForUrl
Public Instance Methods
to_csv()
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 7 def to_csv generate_csv(data) end
to_json()
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 11 def to_json generate_json(data) end
Private Instance Methods
generate_csv(cards)
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 17 def generate_csv(cards) CSV.generate do |csv| csv << ['Card Name', 'Estimated Time', 'Actual Time', 'Members'] cards.each do |card| title, estimated_hours, actual_hours, members = get_relevant_data(card) csv << [title, estimated_hours, actual_hours, members] end end end
generate_json(cards)
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 27 def generate_json(cards) relevant_data = cards.map do |card| title, estimated_hours, actual_hours, members = get_relevant_data(card) { 'card_name': title, 'estimated_time': estimated_hours, 'actual_hours': actual_hours, 'members': members } end JSON.pretty_generate(relevant_data) end
get_actual_hours(title)
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 60 def get_actual_hours(title) actual_hours = '' if title[-1] == ']' open_bracket_index = title.rindex('[') actual_hours = title[open_bracket_index + 1..-2] actual_hours_brackets = title[open_bracket_index..-1] title = title.sub(actual_hours_brackets, '') title = title.strip end return actual_hours, title end
get_estimated_hours(title)
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 48 def get_estimated_hours(title) estimated_hours = '' if title[0] == '(' close_paren_index = title.index(')') estimated_hours = title[1..close_paren_index - 1] estimated_hours_parens = title[0..close_paren_index] title = title.sub(estimated_hours_parens, '') title = title.strip end return estimated_hours, title end
get_members(card)
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 72 def get_members(card) card.members.map { |member| member.full_name }.join(', ') end
get_relevant_data(card)
click to toggle source
# File lib/trello_dxy/formatters/board_for_url.rb, line 40 def get_relevant_data(card) title = card.name.strip estimated_hours, title = get_estimated_hours(title) actual_hours, title = get_actual_hours(title) members = get_members(card) return title, estimated_hours, actual_hours, members end