Class: Gollum::WebSequenceDiagram
- Inherits:
-
Object
- Object
- Gollum::WebSequenceDiagram
- Defined in:
- lib/gollum-lib/web_sequence_diagram.rb
Constant Summary collapse
- WSD_URL =
"http://www.websequencediagrams.com/index.php"
Instance Method Summary collapse
-
#initialize(code, style) ⇒ WebSequenceDiagram
constructor
Initialize a new WebSequenceDiagram object.
-
#render ⇒ Object
Render the sequence diagram on the remote server and store the url to the rendered image.
-
#to_tag ⇒ Object
Gets the HTML IMG tag for the sequence diagram.
Constructor Details
#initialize(code, style) ⇒ WebSequenceDiagram
Initialize a new WebSequenceDiagram object.
code - The String containing the sequence diagram markup. style - The String containing the rendering style.
Returns a new Gollum::WebSequenceDiagram object
15 16 17 18 19 20 21 |
# File 'lib/gollum-lib/web_sequence_diagram.rb', line 15 def initialize(code, style) @code = code @style = style @tag = "" render end |
Instance Method Details
#render ⇒ Object
Render the sequence diagram on the remote server and store the url to the rendered image.
Returns nil.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gollum-lib/web_sequence_diagram.rb', line 27 def render response = Net::HTTP.post_form(URI.parse(WSD_URL), 'style' => @style, 'message' => @code) if response.body =~ /img: "(.+)"/ url = "http://www.websequencediagrams.com/#{$1}" @tag = "<img src=\"#{url}\" />" else puts response.body @tag ="Sorry, unable to render sequence diagram at this time." end end |
#to_tag ⇒ Object
Gets the HTML IMG tag for the sequence diagram.
Returns a String containing the IMG tag.
41 42 43 |
# File 'lib/gollum-lib/web_sequence_diagram.rb', line 41 def to_tag @tag end |