Class: Keynote::Document
- Inherits:
-
Object
- Object
- Keynote::Document
- Extended by:
- Util
- Includes:
- Util
- Defined in:
- lib/keynote/document.rb
Defined Under Namespace
Classes: DocumentInvalid
Constant Summary collapse
- DEFAULT_WIDTH =
1024
- DEFAULT_HEIGHT =
768
- WIDE_WIDTH =
1900
- WIDE_HEIGHT =
1080
Instance Attribute Summary collapse
-
#auto_loop ⇒ Object
Returns the value of attribute auto_loop.
-
#auto_play ⇒ Object
Returns the value of attribute auto_play.
-
#auto_restart ⇒ Object
Returns the value of attribute auto_restart.
-
#current_slide ⇒ Object
Returns the value of attribute current_slide.
-
#document_theme ⇒ Object
Returns the value of attribute document_theme.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#master_slides ⇒ Object
Returns the value of attribute master_slides.
-
#maximum_idle_duration ⇒ Object
Returns the value of attribute maximum_idle_duration.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slide_numbers_showing ⇒ Object
Returns the value of attribute slide_numbers_showing.
-
#slides ⇒ Object
Returns the value of attribute slides.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(arguments = {}) ⇒ Document
constructor
A new instance of Document.
- #save ⇒ Object
- #save! ⇒ Object
Methods included from Util
Constructor Details
#initialize(arguments = {}) ⇒ Document
Returns a new instance of Document.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/keynote/document.rb', line 31 def initialize(arguments = {}) @document_theme = arguments[:theme] || Theme.default @width = arguments.has_key?(:wide) && arguments[:wide] ? WIDE_WIDTH : DEFAULT_WIDTH @height = arguments.has_key?(:wide) && arguments[:wide] ? WIDE_HEIGHT : DEFAULT_HEIGHT @file_path = arguments[:file_path] @id = arguments[:id] @maximum_idle_duration = arguments[:maximumIdleDuration] @current_slide = arguments[:currentSlide] @slide_numbers_showing = arguments[:slideNumbersShowing] @auto_loop = arguments[:autoLoop] @auto_play = arguments[:autoPlay] @auto_restart = arguments[:autoRestart] @maximum_idle_duration = arguments[:maximumIdleDuration] @name = arguments[:name] end |
Instance Attribute Details
#auto_loop ⇒ Object
Returns the value of attribute auto_loop.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def auto_loop @auto_loop end |
#auto_play ⇒ Object
Returns the value of attribute auto_play.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def auto_play @auto_play end |
#auto_restart ⇒ Object
Returns the value of attribute auto_restart.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def auto_restart @auto_restart end |
#current_slide ⇒ Object
Returns the value of attribute current_slide.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def @current_slide end |
#document_theme ⇒ Object
Returns the value of attribute document_theme.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def document_theme @document_theme end |
#height ⇒ Object
Returns the value of attribute height.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def height @height end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
24 25 26 |
# File 'lib/keynote/document.rb', line 24 def id @id end |
#master_slides ⇒ Object
Returns the value of attribute master_slides.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def @master_slides end |
#maximum_idle_duration ⇒ Object
Returns the value of attribute maximum_idle_duration.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def maximum_idle_duration @maximum_idle_duration end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def name @name end |
#slide_numbers_showing ⇒ Object
Returns the value of attribute slide_numbers_showing.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def @slide_numbers_showing end |
#slides ⇒ Object
Returns the value of attribute slides.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def @slides end |
#width ⇒ Object
Returns the value of attribute width.
8 9 10 |
# File 'lib/keynote/document.rb', line 8 def width @width end |
Class Method Details
.all ⇒ Object
149 150 151 |
# File 'lib/keynote/document.rb', line 149 def self.all self.find_with_conditions end |
.create(arguments = {}) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/keynote/document.rb', line 132 def self.create(arguments = {}) theme = arguments[:theme] || Theme.default width = arguments[:wide] ? WIDE_WIDTH : DEFAULT_WIDTH height = arguments[:wide] ? WIDE_HEIGHT : DEFAULT_HEIGHT file_path = arguments[:file_path] result = eval_script <<-APPLE.unindent var Keynote = Application("Keynote") var theme = Keynote.themes.whose({ id: "#{theme.id}" }).first var doc = Keynote.Document({ documentTheme: theme, width: #{width}, height: #{height} }); Keynote.documents.push(doc); JSON.stringify(doc.properties()); APPLE self.new(symbolize_keys(result).merge(theme: theme, width: width, height: height, file_path: file_path)) end |
.current ⇒ Object
165 166 167 |
# File 'lib/keynote/document.rb', line 165 def self.current self.all.first end |
.find_by(args) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/keynote/document.rb', line 153 def self.find_by(args) raise ArgumentError.new('nil argument is given') unless args if args.is_a?(Hash) && args.has_key?(:id) conditions = ".whose({ id: '#{args[:id]}' })" else raise ArgumentError.new('Unsupported argument is given') end find_with_conditions(conditions) end |
Instance Method Details
#export ⇒ Object
128 129 130 |
# File 'lib/keynote/document.rb', line 128 def export # TBD end |
#save ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/keynote/document.rb', line 108 def save return false unless @id return false unless @file_path eval_script <<-APPLE.unindent var Keynote = Application("Keynote") var doc = Keynote.documents.byId("#{@id}") var path = Path("#{@file_path}") doc.save({ in: path }) APPLE true rescue => e false end |
#save! ⇒ Object
124 125 126 |
# File 'lib/keynote/document.rb', line 124 def save! raise DocumentInvalid unless save end |