Class: Rucola::Nib::Classes

Inherits:
Object show all
Defined in:
lib/rucola/nib.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(classes_nib_path) ⇒ Classes

Returns a new instance of Classes.



28
29
30
31
# File 'lib/rucola/nib.rb', line 28

def initialize(classes_nib_path)
  @path = File.expand_path(classes_nib_path)
  @data = OSX::NSDictionary.dictionaryWithContentsOfFile(@path)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



22
23
24
# File 'lib/rucola/nib.rb', line 22

def data
  @data
end

Class Method Details

.open(classes_nib_path) ⇒ Object



24
25
26
# File 'lib/rucola/nib.rb', line 24

def self.open(classes_nib_path)
  new(classes_nib_path)
end

Instance Method Details

#add_class(class_name, superclass_name = 'NSObject') ⇒ Object



37
38
39
40
41
42
43
# File 'lib/rucola/nib.rb', line 37

def add_class(class_name, superclass_name = 'NSObject')
  classes.push({
    'CLASS' => class_name,
    'SUPERCLASS' => superclass_name,
    'LANGUAGE' => 'ObjC'
  })
end

#classesObject



33
34
35
# File 'lib/rucola/nib.rb', line 33

def classes
  @data['IBClasses']
end

#has_class?(class_name) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/rucola/nib.rb', line 45

def has_class?(class_name)
  classes.any? { |klass| klass['CLASS'] == class_name }
end

#saveObject



49
50
51
52
# File 'lib/rucola/nib.rb', line 49

def save
  Rucola::Nib.backup(@path)
  @data.writeToFile_atomically(@path, true)
end