Class: Gollum::WebSequenceDiagram
- Inherits:
-
Object
- Object
- Gollum::WebSequenceDiagram
- Defined in:
- lib/gollum/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
14 15 16 17 18 19 20 |
# File 'lib/gollum/web_sequence_diagram.rb', line 14 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.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gollum/web_sequence_diagram.rb', line 26 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.
40 41 42 |
# File 'lib/gollum/web_sequence_diagram.rb', line 40 def to_tag @tag end |