Class: Resources::Base
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- Resources::Base
show all
- Defined in:
- lib/minglr/resources/base.rb
Class Method Summary
collapse
Class Method Details
7
8
9
10
11
12
|
# File 'lib/minglr/resources/base.rb', line 7
def self.configure(uri_options)
uri = URI.parse(uri_options[:url])
uri.user = uri_options[:username]
uri.password = uri_options[:password]
self.site = uri
end
|
.print_collection(collection, attributes, align = :left) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/minglr/resources/base.rb', line 14
def self.print_collection(collection, attributes, align = :left)
output = []
longest_attributes = Array.new(attributes.length, 0)
alignment = (align == :left ? :ljust : :rjust)
collection.each do |element|
entry = []
attributes.each_with_index do |attribute, index|
attribute_value = element.send(attribute).to_s
longest_attributes[index] = attribute_value.length if attribute_value.length > longest_attributes[index]
entry << attribute_value
end
output << entry
end
output.each do |entry|
row = []
entry.each_with_index do |part, index|
row << [part.send(alignment, longest_attributes[index])]
end
puts row.join(" - ")
end
end
|
.warn(message) ⇒ Object
36
37
38
|
# File 'lib/minglr/resources/base.rb', line 36
def self.warn(message)
puts "Warning: #{message}"
end
|