[ create a new paste ] login | about

Link: http://codepad.org/tCKCE8Xy    [ raw code | output | fork ]

Ruby, pasted on Jan 18:
class Agent
  attr_accessor :name, :location, :clearance, :active

  def initialize(attributes = {})
    @name = attributes[:name]
    @location = attributes[:location]
    @clearnace = attributes[:clearance]
    @active = attributes[:active]
  end

  def show_agent
    maintext = "Agent #{@name} is in #{@location || 'an unknown location'}.  Clearance #{@clearance}"
    if (self.active == "Y") 
      "#{maintext} -- ACTIVE"
    else 
      "#{maintext} -- inactive"
    end
  end

end

arr = []
arr << Agent.new( :name=>'bob' )
puts arr.first.show_agent


Output:
1
Agent bob is in an unknown location.  Clearance  -- inactive


Create a new paste based on this one


Comments: