class Ryb::SourceFile
Constants
- EXTENSIONS_TO_LANGUAGE
- INCONSEQUENTIAL
Attributes
inconsequential[R]
language[R]
path[R]
Public Class Methods
c(path)
click to toggle source
# File lib/ryb/source_file.rb, line 23 def self.c(path) SourceFile.new(path, :language => :c) end
cpp(path)
click to toggle source
# File lib/ryb/source_file.rb, line 27 def self.cpp(path) SourceFile.new(path, :language => :cpp) end
csharp(path)
click to toggle source
# File lib/ryb/source_file.rb, line 31 def self.csharp(path) SourceFile.new(path, :language => :csharp) end
inconsequential?(path)
click to toggle source
# File lib/ryb/source_file.rb, line 56 def self.inconsequential?(path) if ext = File.extname(path)[1..-1] INCONSEQUENTIAL.include? ext end end
language_from_extension(ext)
click to toggle source
# File lib/ryb/source_file.rb, line 47 def self.language_from_extension(ext) EXTENSIONS_TO_LANGUAGE.each do |extensions, language| return language if extensions.include?(ext) end :unknown end
language_from_path(path)
click to toggle source
# File lib/ryb/source_file.rb, line 35 def self.language_from_path(path) if ext = File.extname(path)[1..-1] self.language_from_extension(ext) end end
new(path, opts={})
click to toggle source
# File lib/ryb/source_file.rb, line 7 def initialize(path, opts={}) @path = path @language = opts[:language] || SourceFile.language_from_path(path) @inconsequential = SourceFile.inconsequential?(@path) # TODO(mtwilliams): Use Ryb::UnsupportedLanguage. unless Ryb::Languages.supported?(@language) raise "..." unless @inconsequential end end
Public Instance Methods
==(other)
click to toggle source
# File lib/ryb/source_file.rb, line 19 def ==(other) self.path == other.path end
Also aliased as: eql?