Class: Moo::Design

Inherits:
Object
  • Object
show all
Defined in:
lib/design.rb

Direct Known Subclasses

Greetingcard, MiniCard, Notecard, Postcard, Sticker

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disable_attributes(attributes = []) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/design.rb', line 29

def self.disable_attributes(attributes=[])
  attributes.each do |attribute|
    class_eval %{
      def #{attribute}=(*args)
        raise DisabledAttributeError
      end
    }
  end
end

Instance Method Details

#default_optionsObject



4
5
6
7
8
9
10
# File 'lib/design.rb', line 4

def default_options
  {
    :lines => [],
    :crop => 'auto',
    :type => 'variable'
  }
end

#line(n) ⇒ Object



16
17
18
# File 'lib/design.rb', line 16

def line(n)
  lines[n-1]
end

#text=(content) ⇒ Object



12
13
14
# File 'lib/design.rb', line 12

def text=(content)
  content.split("\n").each{|line| lines << TextLine.new(:string => line, :design => self) }
end

#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/design.rb', line 39

def to_xml(xml=Builder::XmlMarkup.new)
  xml.design {
    xml.image {
      xml.url self.url
      xml.type self.type
      xml.crop {
        xml.auto true
      }
    }
    if !product_type.eql?("sticker")
      xml.text_collection {
        xml.tag!(product_type) {
          lines.each_with_index do |line, index|
            xml.text_line {
              xml.id index+1
              xml.string line.string
              xml.bold line.bold
              xml.align line.align
              xml.font line.font
              xml.colour line.colour
            }
          end
        }
      }
    end
  }
end