Module: Graffle::Builders
- Included in:
- AbstractGraphic, Document, Group, LineGraphic, ShapedGraphic, Sheet
- Defined in:
- lib/graffle/stereotypes.rb
Overview
:nodoc:
Class Method Summary collapse
- .classed(mod, basic_structure = {}, &block) ⇒ Object
- .raw(mod, basic_structure = {}, &block) ⇒ Object
Instance Method Summary collapse
- #abstract_graphic(&block) ⇒ Object
- #annotation(string) ⇒ Object
- #document(&block) ⇒ Object
- #group(&block) ⇒ Object
- #line_graphic(&block) ⇒ Object
- #line_label(&block) ⇒ Object
- #shaped_graphic(&block) ⇒ Object
- #sheet(&block) ⇒ Object
- #text(string, &block) ⇒ Object
Class Method Details
.classed(mod, basic_structure = {}, &block) ⇒ Object
17 18 19 20 21 |
# File 'lib/graffle/stereotypes.rb', line 17 def self.classed(mod, basic_structure = {}, &block) prog1(raw(mod, basic_structure, &block)) do | g | g['Class'] = mod.basename end end |
.raw(mod, basic_structure = {}, &block) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/graffle/stereotypes.rb', line 10 def self.raw(mod, basic_structure = {}, &block) prog1(basic_structure.dup) do | g | g.behave_like(mod) g.instance_eval(&block) if block end end |
Instance Method Details
#abstract_graphic(&block) ⇒ Object
23 24 25 |
# File 'lib/graffle/stereotypes.rb', line 23 def abstract_graphic(&block) Builders.raw(Graffle::AbstractGraphic, &block) end |
#annotation(string) ⇒ Object
62 63 64 |
# File 'lib/graffle/stereotypes.rb', line 62 def annotation(string) prog1(string) { | s | s.behave_like(Graffle::Note) } end |
#document(&block) ⇒ Object
50 51 52 53 54 |
# File 'lib/graffle/stereotypes.rb', line 50 def document(&block) prog1(Builders.raw(Graffle::Document, &block)) { | doc | doc['Creator'] = 'graffle.rb' } end |
#group(&block) ⇒ Object
46 47 48 |
# File 'lib/graffle/stereotypes.rb', line 46 def group(&block) Builders.classed(Graffle::Group, {'Graphics' => []}, &block) end |
#line_graphic(&block) ⇒ Object
38 39 40 |
# File 'lib/graffle/stereotypes.rb', line 38 def line_graphic(&block) Builders.classed(Graffle::LineGraphic, &block) end |
#line_label(&block) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/graffle/stereotypes.rb', line 31 def line_label(&block) prog1(shaped_graphic) do | g | g.act_as_line_label g.instance_eval(&block) if block end end |
#shaped_graphic(&block) ⇒ Object
27 28 29 |
# File 'lib/graffle/stereotypes.rb', line 27 def shaped_graphic(&block) Builders.classed(Graffle::ShapedGraphic, &block) end |