Sha256: c7b4d0ab042b2e0a1c8deb200e13448b15a3bed322ed91ea505ef1c801447141

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'pathname'

module Dsfu
  class Product
    attr_reader :file_name, :display_name, :height, :width, :description, :price, :category
    attr_accessor :image_path, :company, :category

    def initialize(opts)
      @file_name = opts[:file_name]
      @display_name = opts[:display_name]
      @height = opts[:height]
      @width = opts[:width]
      @price = opts[:price]
      @company = opts[:company] || nil
      @category = opts[:category]
      @description = opts[:description] || nil
      @image_path = opts[:image_path] || nil
    end

    def display_description
      string = []
      string << dimensions
      string << description
      string.join("\n")
    end

    def dimensions
      "#{width}\" x #{height}\""
    end

    def name
      @company + " " + @category + " " + @display_name
    end

    def find_image_path
      self.image_path = File.expand_path(Pathname.glob("#{file_name}")[0].to_path)
    end

    def strip?
      DSFU::Size.new(width, height).strip?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dsfu-0.0.1 lib/dsfu/product.rb