Class: ProcessingIde

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby_art/processing_ide.rb

Overview

detects processing preferences.txt, extracts sketchbook_path

Constant Summary collapse

THREE =
'sketchbook.path.three='.freeze
FOUR =
'sketchbook.path.four='.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcessingIde

Returns a new instance of ProcessingIde.



8
9
10
# File 'lib/jruby_art/processing_ide.rb', line 8

def initialize
  @preferences = File.join(ENV['HOME'], '.processing', 'preferences.txt')
end

Instance Attribute Details

#preferencesObject (readonly)

Returns the value of attribute preferences.



7
8
9
# File 'lib/jruby_art/processing_ide.rb', line 7

def preferences
  @preferences
end

Instance Method Details

#installed?Boolean

Returns:

  • (Boolean)


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

def installed?
  File.exist?(preferences)
end

#sketchbook_pathObject



16
17
18
19
20
21
22
23
24
# File 'lib/jruby_art/processing_ide.rb', line 16

def sketchbook_path
  File.open(preferences, 'r') do |file|
    file.each_line do |line|
      return line.tap { |sli| sli.slice!(FOUR) }.chomp if /sketchbook.path.four/.match?(line)

      return line.tap { |sli| sli.slice!(THREE) }.chomp if /sketchbook.path.three/.match?(line)
    end
  end
end