Extends File class and add new method : subclass File « File Directory « Ruby






Extends File class and add new method


class MyFile < File
  def MyFile.ftype(*args)
    return "The type is #{super}."
  end
end

File.ftype("/bin")                        # => "directory"
puts MyFile.ftype("/bin")                      # => "The type is directory."

 








Related examples in the same category