Meeting Update: Monday January 21, 2013

  • Each class can have one instance.
  • <file>.data is written automatically when a change is made to any instance variable.
  • The instance variables will be modified by the user through a GUI or simple interface.
  • Example

Code highlighting:

#ProblemData.rb

require 'singleton'

class ProblemData
  include Singleton
  
  def self.attr_accessor(*names)
    names.each { |name|
      module_eval %Q{
        attr_reader :#{name}

        def #{name}= (value)
          @#{name} = value
          self.print
        end
      }
    }
  end

  attr_accessor :density, :pressure, :velocity

  def initialize
    @density  = 1
    @pressure = 1
    @velocity = [0,0,0]

    self.print
  end

  def print(filename="problem.data")
    File.new(filename,"w").puts %Q{
&AmbientData
density  = #{@density}
pressure = #{@pressure}
velocity = #{@velocity.join(",")}
/

    }

  end
end

Comments

No comments.