Class: Application::DocumentTypeSpecification

Inherits:
Object
  • Object
show all
Defined in:
lib/hotcocoa/application/document_type_specification.rb

Overview

This class represents the configuration for a document type, used by document-based applications. It is used to generate the Info.plist file

See http://developer.apple.com/library/mac/#documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html for details.

Constant Summary collapse

VALID_ROLES =
{:editor => "Editor", :viewer => "Viewer", :none => "None"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ DocumentTypeSpecification

Returns a new instance of DocumentTypeSpecification.

Yields:

  • (_self)

Yield Parameters:



23
24
25
26
27
28
29
30
31
# File 'lib/hotcocoa/application/document_type_specification.rb', line 23

def initialize
  unless block_given?
    msg = 'You must pass a block at initialization to declare the new document type'
    raise ArgumentError, msg
  end
  yield self
  
  verify!
end

Instance Attribute Details

#class=(value) ⇒ Object (writeonly)

Sets the attribute class

Parameters:

  • value

    the value to set the attribute class to.



21
22
23
# File 'lib/hotcocoa/application/document_type_specification.rb', line 21

def class=(value)
  @class = value
end

#extensions=(value) ⇒ Object (writeonly)

Sets the attribute extensions

Parameters:

  • value

    the value to set the attribute extensions to.



17
18
19
# File 'lib/hotcocoa/application/document_type_specification.rb', line 17

def extensions=(value)
  @extensions = value
end

#icon=(value) ⇒ Object (writeonly)

Sets the attribute icon

Parameters:

  • value

    the value to set the attribute icon to.



18
19
20
# File 'lib/hotcocoa/application/document_type_specification.rb', line 18

def icon=(value)
  @icon = value
end

#name=(value) ⇒ Object (writeonly)

Sets the attribute name

Parameters:

  • value

    the value to set the attribute name to.



19
20
21
# File 'lib/hotcocoa/application/document_type_specification.rb', line 19

def name=(value)
  @name = value
end

#role=(value) ⇒ Object (writeonly)

Sets the attribute role

Parameters:

  • value

    the value to set the attribute role to.



20
21
22
# File 'lib/hotcocoa/application/document_type_specification.rb', line 20

def role=(value)
  @role = value
end

Instance Method Details

#info_plist_representationObject

TODO:

CFBundleTypeMIMETypes

TODO:

LSTypeIsPackage

TODO:

CFBundleTypeOSTypes



36
37
38
39
40
41
42
43
44
# File 'lib/hotcocoa/application/document_type_specification.rb', line 36

def info_plist_representation
  {
    CFBundleTypeExtensions: @extensions,
    CFBundleTypeIconFile:   @icon,
    CFBundleTypeName:       @name,
    CFBundleTypeRole:       VALID_ROLES[@role], 
    NSDocumentClass:        @class
  }
end