Class: Motion::Util::IbHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-util/command/ib_header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



25
26
27
# File 'lib/motion-util/command/ib_header.rb', line 25

def actions
  @actions
end

#class_nameObject (readonly)

Returns the value of attribute class_name.



25
26
27
# File 'lib/motion-util/command/ib_header.rb', line 25

def class_name
  @class_name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



25
26
27
# File 'lib/motion-util/command/ib_header.rb', line 25

def properties
  @properties
end

#super_nameObject (readonly)

Returns the value of attribute super_name.



25
26
27
# File 'lib/motion-util/command/ib_header.rb', line 25

def super_name
  @super_name
end

Instance Method Details

#contextObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/motion-util/command/ib_header.rb', line 32

def context
  lines = []
  lines << "@interface #{@class_name} : #{@super_name || 'NSObject'}"
  
  properties.each do |k, v|
    if v[:readonly]
      lines << "@property (strong, nonatomic, readonly) IBOutlet #{type_name_of v[:type]}#{k};"
    else
      lines << "@property (strong, nonatomic) IBOutlet #{type_name_of v[:type]}#{k};"
    end
  end
  
  actions.each do |a|
    lines << "- (IBAction)#{a[0]}:(id)#{a[1]};"
  end
  
  lines << "@end"
  lines << ""
  lines.join "\n"
end

#dst_name_of(path) ⇒ Object



53
54
55
56
57
58
# File 'lib/motion-util/command/ib_header.rb', line 53

def dst_name_of path
  a = path.split("/")
  a.pop
  a << "#{class_name}.h"
  a.join("/")
end

#source=(source) ⇒ Object



27
28
29
30
# File 'lib/motion-util/command/ib_header.rb', line 27

def source= source
  @source = source
  parse
end