class BooticCli::Commands::Orders::OrdersTable
Attributes
orders[R]
Public Class Methods
call(orders)
click to toggle source
# File lib/bootic_cli/commands/orders.rb, line 5 def self.call(orders) new(orders).data end
new(orders)
click to toggle source
# File lib/bootic_cli/commands/orders.rb, line 9 def initialize(orders) @orders = orders end
Public Instance Methods
data()
click to toggle source
# File lib/bootic_cli/commands/orders.rb, line 13 def data data = [['status', 'updated', 'created', 'code', 'total', 'discount', 'payment', 'client']] data += orders.map do |order| [order.status, order.updated_on, order.created_on, order.code, order.total, discount_line(order), payment_line(order), order_contact_name(order)] end data end
Private Instance Methods
discount_line(order)
click to toggle source
# File lib/bootic_cli/commands/orders.rb, line 29 def discount_line(order) order.discount_total > 0 ? "#{order.discount_total} (#{order.discount_name})" : '' end
order_contact_name(order)
click to toggle source
# File lib/bootic_cli/commands/orders.rb, line 24 def order_contact_name(order) return '' unless order.has?(:contact) "#{order.contact.name} <#{order.contact.email}>" end
payment_line(order)
click to toggle source
# File lib/bootic_cli/commands/orders.rb, line 33 def payment_line(order) order.has?(:payment_info) ? order.payment_info.name : '' end