Module: Octonaut::Printers::Users

Included in:
Octonaut::Printer
Defined in:
lib/octonaut/printers/users.rb

Constant Summary collapse

USER_FIELDS =
{
  "id"         => "ID",
  "login"      => "LOGIN",
  "name"       => "NAME",
  "company"    => "COMPANY",
  "location"   => "LOCATION",
  "followers"  => "FOLLOWERS",
  "following"  => "FOLLOWING",
  "hireable"   => "HIREABLE",
  "blog"       => "URL",
  "created_at" => "JOINED"
}

Instance Method Summary collapse

Instance Method Details

#ls_users(users, options = {}) ⇒ Object



36
37
38
# File 'lib/octonaut/printers/users.rb', line 36

def ls_users(users, options = {})
  users.each {|u| puts u. }
end


31
32
33
34
# File 'lib/octonaut/printers/users.rb', line 31

def print_csv_users(users, options = {})
  options[:fields] = USER_FIELDS
  print_csv users, options
end


18
19
20
21
22
23
24
25
# File 'lib/octonaut/printers/users.rb', line 18

def print_user_table(user, options = {})
  data = {}
  USER_FIELDS.each do |field, heading|
    data[heading] = user[field]
  end

  print_table(data)
end


27
28
29
# File 'lib/octonaut/printers/users.rb', line 27

def print_users(users, options = {})
  options[:csv] ? print_csv_users(users) : ls_users(users)
end