Class: Wsd

Inherits:
Object
  • Object
show all
Defined in:
lib/wsd.rb

Constant Summary collapse

STYLES =
%w(default earth modern-blue mscgen omegapple qsd rose roundgreen napkin)
BASE_URL =
'http://www.websequencediagrams.com'

Instance Method Summary collapse

Constructor Details

#initialize(text, style = STYLES[0]) ⇒ Wsd

Returns a new instance of Wsd.



10
11
12
13
# File 'lib/wsd.rb', line 10

def initialize(text, style=STYLES[0])
  @style = style
  @text = text
end

Instance Method Details

#to_htmlObject



15
16
17
18
19
20
21
# File 'lib/wsd.rb', line 15

def to_html
  output = "<div class='wsd' wsd_style='#{@style}'><pre>\n"
  output << @text
  output << "\n</pre></div>"
  output << "<script type='text/javascript' src='http://www.websequencediagrams.com/service.js'></script>"
  output
end

#write(file = nil) ⇒ Object



23
24
25
26
# File 'lib/wsd.rb', line 23

def write(file=nil)
  file = file || default_file
  File.open(file, "w+") { |f| f << open(diagram_url).read }
end