Class: FlexCocoa

Inherits:
Object
  • Object
show all
Defined in:
lib/flex_cocoa.rb,
lib/flex_cocoa/cc_bubble.rb,
lib/flex_cocoa/cc_progress.rb,
lib/flex_cocoa/cc_input_box.rb,
lib/flex_cocoa/cc_file_select.rb,
lib/flex_cocoa/cc_message_box.rb,
lib/flex_cocoa/cc_secure_input.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = FlexCocoa.set_path) ⇒ FlexCocoa

Returns a new instance of FlexCocoa.



21
22
23
# File 'lib/flex_cocoa.rb', line 21

def initialize (path = FlexCocoa.set_path)
  @exec = path
end

Class Attribute Details

.app_pathObject (readonly)

Returns the value of attribute app_path.



15
16
17
# File 'lib/flex_cocoa.rb', line 15

def app_path
  @app_path
end

Instance Attribute Details

#execObject

Returns the value of attribute exec.



12
13
14
# File 'lib/flex_cocoa.rb', line 12

def exec
  @exec
end

#outputObject

Returns the value of attribute output.



12
13
14
# File 'lib/flex_cocoa.rb', line 12

def output
  @output
end

Class Method Details

.set_path(path = '/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog') ⇒ Object



16
17
18
# File 'lib/flex_cocoa.rb', line 16

def set_path (path = '/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog')
  @app_path = path
end

Instance Method Details

#button_responseObject



48
49
50
# File 'lib/flex_cocoa.rb', line 48

def button_response
  @stdout.read.strip.to_i - 1
end

#buttons_template(type, title, text, i_text, r_button, m_button, l_button) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/flex_cocoa.rb', line 34

def buttons_template (type, title, text, i_text, r_button, m_button, l_button)

  parts_init(
      type,
      :title => title,
      :text => text,
      :'informative-text' => i_text,
      :button1 => r_button,
      :button2 => m_button,
      :button3 => l_button
  )

end

#parts_init(type, args) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/flex_cocoa.rb', line 25

def parts_init (type, args)

  args.each { |key, value|
    @exec << " #{type} --#{key} \"#{value}\"" unless value.nil?
  }
  puts @exec

end

#post_initializeObject



52
53
54
# File 'lib/flex_cocoa.rb', line 52

def post_initialize
  @pid, @stdin, @stdout, @stterr = Open4::popen4(@exec)
end