Class: Brio::Format::CSV
- Inherits:
-
Object
- Object
- Brio::Format::CSV
- Defined in:
- lib/brio/format/csv.rb
Constant Summary collapse
- POST_HEADER =
["id", "timestampt", "username", "text", "replies"]
- USER_HEADER =
["username", "name", "joined", "followers", "following"]
Instance Method Summary collapse
- #print_post(post) ⇒ Object
- #print_posts(posts) ⇒ Object
- #print_user(user) ⇒ Object
- #print_users(users) ⇒ Object
- #set_wrap ⇒ Object
Instance Method Details
#print_post(post) ⇒ Object
18 19 20 |
# File 'lib/brio/format/csv.rb', line 18 def print_post( post ) say [post.id, csv_formatted_time(post.created_at), post.user.username, post.text, post.num_replies].to_csv end |
#print_posts(posts) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/brio/format/csv.rb', line 11 def print_posts( posts ) say POST_HEADER.to_csv posts.each do |post| print_post post end end |
#print_user(user) ⇒ Object
29 30 31 |
# File 'lib/brio/format/csv.rb', line 29 def print_user( user ) say [user.username, user.name, csv_formatted_time(user.created_at), user.counts.followers, user.counts.following].to_csv end |
#print_users(users) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/brio/format/csv.rb', line 22 def print_users( users ) say USER_HEADER.to_csv users.each do |u| print_user u end end |
#set_wrap ⇒ Object
33 34 35 |
# File 'lib/brio/format/csv.rb', line 33 def set_wrap $terminal.wrap_at = :auto end |