Class: Yadriggy::Py::Import
- Inherits:
-
Object
- Object
- Yadriggy::Py::Import
- Defined in:
- lib/yadriggy/py/import.rb
Overview
The import statement in Python.
Constant Summary collapse
- @@src =
''
- @@state =
0
Class Method Summary collapse
-
.from(name) ⇒ Object
from
keyword. -
.import(name) ⇒ Object
import
keyword.
Instance Method Summary collapse
-
#as(name) ⇒ Object
as
keyword. -
#import(name) ⇒ Object
import
keyword.
Class Method Details
.from(name) ⇒ Object
from
keyword.
58 59 60 61 62 63 |
# 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) ⇒ Object
import
keyword.
49 50 51 52 53 54 |
# 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 |
Instance Method Details
#as(name) ⇒ Object
as
keyword.
37 38 39 40 41 42 43 44 45 |
# 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) ⇒ Object
import
keyword.
22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |