Parent

Files

Gollum::WebSequenceDiagram

Constants

WSD_URL

Public Class Methods

new(code, style) click to toggle source

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

# File lib/gollum-lib/web_sequence_diagram.rb, line 14
def initialize(code, style)
  @code = code
  @style = style
  @tag = ""

  render
end

Public Instance Methods

render() click to toggle source

Render the sequence diagram on the remote server and store the url to the rendered image.

Returns nil.

# File lib/gollum-lib/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() click to toggle source

Gets the HTML IMG tag for the sequence diagram.

Returns a String containing the IMG tag.

# File lib/gollum-lib/web_sequence_diagram.rb, line 40
def to_tag
  @tag
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.