Class: Word

Inherits:
Object show all
Defined in:
lib/engine/word.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(visible) ⇒ Word

Returns a new instance of Word.



35
36
37
38
39
40
41
# File 'lib/engine/word.rb', line 35

def initialize( visible )
  @wd = WIN32OLE.new('Word.Application')

  WIN32OLE.const_load(@wd, WORD_OLE_CONST) if WORD_OLE_CONST.constants.empty?

  @wd.Visible = visible
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



33
34
35
# File 'lib/engine/word.rb', line 33

def doc
  @doc
end

#wdObject (readonly)

Returns the value of attribute wd.



33
34
35
# File 'lib/engine/word.rb', line 33

def wd
  @wd
end

Instance Method Details

#open(file) ⇒ Object



43
44
45
46
# File 'lib/engine/word.rb', line 43

def open(file)
  @doc = @wd.Documents.Open(file)
  @doc
end

#quitObject



67
68
69
# File 'lib/engine/word.rb', line 67

def quit
  @wd.quit()
end

#saveObject



48
49
50
51
# File 'lib/engine/word.rb', line 48

def save()
  @doc.Save()
  @doc
end

#save_as(name, format) ⇒ Object

Format : From WORD_OLE_CONST e.g WORD_OLE_CONST::WdFormatHTML



55
56
57
58
# File 'lib/engine/word.rb', line 55

def save_as(name, format)
  @doc.SaveAs(name, format)
  return @doc
end

#save_as_html(name) ⇒ Object

WdFormatFilteredHTML WdFormatHTML



62
63
64
65
# File 'lib/engine/word.rb', line 62

def save_as_html(name)
  @doc.SaveAs(name, WORD_OLE_CONST::WdFormatHTML)
  return @doc
end