Module: Graffle::AbstractGraphic
- Includes:
- Comparable, Builders
- Included in:
- Group, LineGraphic, ShapedGraphic
- Defined in:
- lib/graffle/stereotypes.rb,
lib/graphical_tests_for_rails/stereotype-extensions.rb
Overview
Behavior that’s common to all visible objects, be they lines, rectangles, text objects, etc.
Instance Attribute Summary collapse
-
#container ⇒ Object
The Group or Sheet containing the object.
Class Method Summary collapse
-
.graffle_class_matches?(o, mod) ⇒ Boolean
:nodoc:.
-
.takes_on(o, mod) ⇒ Object
TODO: I’m not wild about the way this both checks if something’s possible and also does it.
Instance Method Summary collapse
-
#any_content_lines ⇒ Object
:nodoc:.
-
#any_note_lines ⇒ Object
:nodoc:.
-
#before?(other) ⇒ Boolean
One AbstractGraphic is before another if its origin starts higher than the other’s.
-
#delete_yourself ⇒ Object
Delete this graphic from inside its Container (a Sheet or a Group).
-
#graffle_id ⇒ Object
Every visible graffle object has an integer ID.
-
#graffle_id_is(id) ⇒ Object
:nodoc:.
-
#has_any_content? ⇒ Boolean
:nodoc:.
-
#has_any_note? ⇒ Boolean
:nodoc:.
-
#has_line_label_content? ⇒ Boolean
:nodoc:.
-
#has_line_label_note? ⇒ Boolean
:nodoc:.
-
#has_line_note? ⇒ Boolean
:nodoc:.
-
#has_note? ⇒ Boolean
(also: #has_notes?)
Does this object contain a note? (Notes are an OmniGraffle Pro feature).
-
#has_shaped_graphic_content? ⇒ Boolean
:nodoc:.
-
#has_shaped_graphic_note? ⇒ Boolean
:nodoc:.
-
#is_labeled_line? ⇒ Boolean
These are utilities of use when you’re handed an abstract graphic and want to know something about it.
-
#is_line_label? ⇒ Boolean
Is this object the label for some LineGraphic?.
-
#notes ⇒ Object
(also: #note)
OmniGraffle Pro objects can have notes attached to them.
-
#origin ⇒ Object
A Point.
-
#with_notes(string) ⇒ Object
(also: #with_note)
:nodoc:.
Methods included from Builders
#abstract_graphic, #annotation, classed, #document, #group, #line_graphic, #line_label, raw, #shaped_graphic, #sheet, #text
Instance Attribute Details
#container ⇒ Object
The Group or Sheet containing the object. Mostly for internal use.
93 94 95 |
# File 'lib/graffle/stereotypes.rb', line 93 def container @container end |
Class Method Details
.graffle_class_matches?(o, mod) ⇒ Boolean
:nodoc:
88 89 90 |
# File 'lib/graffle/stereotypes.rb', line 88 def self.graffle_class_matches?(o, mod) # :nodoc: o.is_a?(Hash) && o['Class'] == mod.basename end |
.takes_on(o, mod) ⇒ Object
TODO: I’m not wild about the way this both checks if something’s possible and also does it. Separate in caller?
80 81 82 83 84 85 86 |
# File 'lib/graffle/stereotypes.rb', line 80 def self.takes_on(o, mod) # :nodoc: if graffle_class_matches?(o, mod) o.behave_like(mod) o.notes.behave_like(Note) if o.has_notes? return true end end |
Instance Method Details
#any_content_lines ⇒ Object
:nodoc:
61 62 63 64 65 66 67 68 69 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 61 def any_content_lines # :nodoc: if has_shaped_graphic_content? shaped_graphic_content_lines elsif has_line_label_content? line_label_content_lines else user_is_bewildered("#{self.inspect} doesn't have content.") end end |
#any_note_lines ⇒ Object
:nodoc:
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 72 def any_note_lines # :nodoc: if has_shaped_graphic_note? shaped_graphic_note_lines elsif has_line_note? line_note_lines elsif has_line_label_note? line_label_note_lines else user_is_bewildered("#{self.inspect} doesn't have content.") end end |
#before?(other) ⇒ Boolean
One AbstractGraphic is before another if its origin starts higher than the other’s. If their origins are at the same height, the one furthest to the left comes before.
105 106 107 |
# File 'lib/graffle/stereotypes.rb', line 105 def before?(other) self.origin < other.origin end |
#delete_yourself ⇒ Object
Delete this graphic from inside its Container (a Sheet or a Group). The name is delete_yourself to avoid overriding the delete method on the underlying class.
141 142 143 |
# File 'lib/graffle/stereotypes.rb', line 141 def delete_yourself container.delete_graphic(self) end |
#graffle_id ⇒ Object
Every visible graffle object has an integer ID. Mostly for internal use.
97 |
# File 'lib/graffle/stereotypes.rb', line 97 def graffle_id; self['ID']; end |
#graffle_id_is(id) ⇒ Object
:nodoc:
98 99 100 |
# File 'lib/graffle/stereotypes.rb', line 98 def graffle_id_is(id) # :nodoc: self['ID'] = id end |
#has_any_content? ⇒ Boolean
:nodoc:
50 51 52 53 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 50 def has_any_content? # :nodoc: return true if behaves_like?(ShapedGraphic) && has_content? has_line_label_content? end |
#has_any_note? ⇒ Boolean
:nodoc:
55 56 57 58 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 55 def has_any_note? # :nodoc: return true if has_note? has_line_label_note? end |
#has_line_label_content? ⇒ Boolean
:nodoc:
34 35 36 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 34 def has_line_label_content? # :nodoc: is_labeled_line? && label.has_content? end |
#has_line_label_note? ⇒ Boolean
:nodoc:
30 31 32 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 30 def has_line_label_note? # :nodoc: is_labeled_line? && label.has_note? end |
#has_line_note? ⇒ Boolean
:nodoc:
38 39 40 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 38 def has_line_note? # :nodoc: behaves_like?(LineGraphic) && has_note? end |
#has_note? ⇒ Boolean Also known as: has_notes?
Does this object contain a note? (Notes are an OmniGraffle Pro feature)
135 |
# File 'lib/graffle/stereotypes.rb', line 135 def has_note?; self.has_key?('Notes'); end |
#has_shaped_graphic_content? ⇒ Boolean
:nodoc:
46 47 48 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 46 def has_shaped_graphic_content? # :nodoc: behaves_like?(ShapedGraphic) && has_content? end |
#has_shaped_graphic_note? ⇒ Boolean
:nodoc:
42 43 44 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 42 def has_shaped_graphic_note? # :nodoc: behaves_like?(ShapedGraphic) && has_note? end |
#is_labeled_line? ⇒ Boolean
These are utilities of use when you’re handed an abstract graphic and want to know something about it.
25 26 27 28 |
# File 'lib/graphical_tests_for_rails/stereotype-extensions.rb', line 25 def is_labeled_line? # :nodoc: return false unless behaves_like?(LineGraphic) has_label? end |
#is_line_label? ⇒ Boolean
Is this object the label for some LineGraphic?
110 |
# File 'lib/graffle/stereotypes.rb', line 110 def is_line_label?; self.has_key?('Line'); end |
#notes ⇒ Object Also known as: note
OmniGraffle Pro objects can have notes attached to them. A note is just an RTF string. If there is no note, the return value is a null object that responds to as_lines with an empty array.
119 120 121 122 123 124 125 |
# File 'lib/graffle/stereotypes.rb', line 119 def notes if has_key?('Notes') self['Notes'] else Text::Null.new end end |
#origin ⇒ Object
A Point. Must be defined in the whatever includes this module.
113 |
# File 'lib/graffle/stereotypes.rb', line 113 def origin; includer_responsibility; end |
#with_notes(string) ⇒ Object Also known as: with_note
:nodoc:
128 129 130 |
# File 'lib/graffle/stereotypes.rb', line 128 def with_notes(string) # :nodoc: self['Notes'] = annotation(string) end |