lib/ronin/product.rb in ronin-0.2.2 vs lib/ronin/product.rb in ronin-0.2.3
- old
+ new
@@ -44,16 +44,33 @@
# Validates
validates_present :name, :version
#
+ # Creates a new Product object with the given _attributes_.
+ #
+ # _attributes_ must contain the following keys:
+ # <tt>:name</tt>:: The name of the product.
+ # <tt>:vendor</tt>:: The vendor of the product. Will default to the
+ # product name, if not given.
+ #
+ # _attributes_ may contain the following keys:
+ # <tt>:version</tt>:: The version of the product.
+ #
+ def initialize(attributes={})
+ attributes[:vendor] ||= attributes[:name]
+
+ super(attributes)
+ end
+
+ #
# Returns the String form of the product.
#
def to_s
- unless @vendor==@name
- return "#{@vendor} #{@name} #{@version}"
+ unless self.vendor == self.name
+ return "#{self.vendor} #{self.name} #{self.version}"
else
- return "#{@name} #{@version}"
+ return "#{self.name} #{self.version}"
end
end
end
end