Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add Printer#display_name

The 'display_name' attributes holds the name a user has assigned to a
printer. Make this accessible as well, as it will probably be more
useful than 'name' in many cases.
  • Loading branch information...
commit 95fa2331cb88adb652fbd4e74b310c92f69b096d 1 parent bcd5d1e
@minciue authored
Showing with 9 additions and 5 deletions.
  1. +3 −2 lib/cloudprint/printer.rb
  2. +6 −3 test/printer_test.rb
View
5 lib/cloudprint/printer.rb
@@ -1,10 +1,11 @@
module CloudPrint
class Printer
- attr_reader :id, :status, :name, :tags
+ attr_reader :id, :status, :name, :tags, :display_name
def initialize(options = {})
@id = options[:id]
@status = options[:status]
@name = options[:name]
+ @display_name = options[:display_name]
@tags = options[:tags] || {}
end
@@ -30,7 +31,7 @@ def all
private
def new_from_hash(hash)
- Printer.new(:id => hash['id'], :status => hash['status'], :name => hash['name'], :tags => hash['tags'])
+ Printer.new(:id => hash['id'], :status => hash['status'], :name => hash['name'], :display_name => hash['displayName'], :tags => hash['tags'])
end
end
end
View
9 test/printer_test.rb
@@ -59,6 +59,9 @@ def setup
assert_equal 'second_printer', second_printer.id
assert_equal 'First Printer', first_printer.name
assert_equal 'Second Printer', second_printer.name
+ assert_equal 'First Printer (display name)', first_printer.display_name
+ assert_equal 'Second Printer (display name)', second_printer.display_name
+
end
should "print stuff" do
@@ -133,13 +136,13 @@ def connection_print_file_params
end
def one_printer_hash
- {'printers' =>[{'id' => 'my_printer', 'status' => 'online', 'name' => "My Printer", 'tags' => { 'email' => 'a@b.com'}}]}
+ {'printers' =>[{'id' => 'my_printer', 'status' => 'online', 'name' => "My Printer", 'displayName' => 'My Printer (display name)', 'tags' => { 'email' => 'a@b.com'}}]}
end
def multiple_printer_hash
{'printers' =>[
- {'id' => 'first_printer', 'status' => 'online', 'name' => "First Printer"},
- {'id' => 'second_printer', 'status' => 'online', 'name' => "Second Printer"}
+ {'id' => 'first_printer', 'status' => 'online', 'name' => "First Printer", 'displayName' => 'First Printer (display name)'},
+ {'id' => 'second_printer', 'status' => 'online', 'name' => "Second Printer", 'displayName' => 'Second Printer (display name)'}
]}
end
Please sign in to comment.
Something went wrong with that request. Please try again.