Class: Konjac::Office::Mac::Shared
- Defined in:
- lib/konjac/office/mac/shared.rb
Overview
Inherits from Base and adds some shared methods to the Mac interface
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#close(opts = {}) ⇒ Object
Closes the document.
-
#initialize(app_name, path = nil) ⇒ Shared
constructor
Creates a new Shared object.
-
#open(path) ⇒ Object
Open the document at the supplied
path
using the current application. -
#path ⇒ Object
Retrieves the POSIX path of the document.
Methods inherited from Base
#[], #[]=, #export, #import, #read, #shape_at, #tags, #write
Constructor Details
#initialize(app_name, path = nil) ⇒ Shared
Creates a new Shared object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/konjac/office/mac/shared.rb', line 10 def initialize(app_name, path = nil) @application = Appscript.app(app_name) super path @item_opts.merge!({ :read => :get, :write => :set }) @shape_opts.merge!({ :read => :get, :write => :set }) end |
Instance Method Details
#close(opts = {}) ⇒ Object
Closes the document. If :saving
is set to true
the document will be saved first. If it’s set to false
the document will not be saved.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/konjac/office/mac/shared.rb', line 31 def close(opts = {}) opts[:saving] = case opts[:saving] when true :yes when false :no else nil end @document.close :saving => opts[:saving] end |
#open(path) ⇒ Object
Open the document at the supplied path
using the current application
24 25 26 |
# File 'lib/konjac/office/mac/shared.rb', line 24 def open(path) @application.open path end |
#path ⇒ Object
Retrieves the POSIX path of the document
44 45 46 |
# File 'lib/konjac/office/mac/shared.rb', line 44 def path @path ||= posix_path(@document.full_name.get) end |