class Yadriggy::Py::Import
The import statement in Python.
Public Class Methods
error(name)
click to toggle source
@api private
# File lib/yadriggy/py/import.rb, line 66 def self.error(name) self.source raise RuntimeError.new("bad call to Import\##{name}") end
from(name)
click to toggle source
`from` keyword. @param [String|Symbol] name a module name.
# File lib/yadriggy/py/import.rb, line 58 def self.from(name) error('from') if @@state == 3 @@src << "\nfrom " << name.to_s @@state = 3 Import.new end
import(name)
click to toggle source
`import` keyword. @param [String|Symbol] name a module name.
# File lib/yadriggy/py/import.rb, line 49 def self.import(name) error('import') if @@state == 3 @@src << "\nimport " << name.to_s @@state = 1 Import.new end
source()
click to toggle source
@api private
# File lib/yadriggy/py/import.rb, line 13 def self.source src = @@src @@src = '' @@state = 0 src end
Public Instance Methods
as(name)
click to toggle source
`as` keyword. @param [String|Symbol] name an alias.
# File lib/yadriggy/py/import.rb, line 37 def as(name) if @@state == 1 @@src << ' as ' << name.to_s @@state = 2 else Import.error('as') end self end
import(name)
click to toggle source
`import` keyword. @param [String|Symbol] name a module name etc.
# File lib/yadriggy/py/import.rb, line 22 def import(name) if @@state == 1 || @@state == 2 @@src << ', ' << name.to_s @@state = 1 elsif @@state == 3 @@src << ' import ' << name.to_s @@state = 1 else Import.error('import') end self end