Module: Sal::Format
- Included in:
- Item
- Defined in:
- lib/sal/format.rb
Overview
Analyzes the file format from the sal sourcecode The result is one of the constantsTEXT, NORMAL or INDENTED.
Constant Summary collapse
- TEXT =
:t
- NORMAL =
:n
- INDENTED =
:i
Class Method Summary collapse
-
.get_from_code(code) ⇒ Object
Analyzes the file format for the given chunk of code.
-
.get_from_file(filename) ⇒ Object
Analyzes the file format for the file with the given filename The file is read and the source code sends to the method get_from_code.
- .get_from_line(line) ⇒ Object
Class Method Details
.get_from_code(code) ⇒ Object
Analyzes the file format for the given chunk of code
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sal/format.rb', line 12 def Format.get_from_code( code ) if(code =~ /Outline Version - \d\.\d\.(\d\d)/m) if(code =~ /^\.head/) return Format::TEXT else return Format::INDENTED end else return Format::NORMAL end end |
.get_from_file(filename) ⇒ Object
Analyzes the file format for the file with the given filename The file is read and the source code sends to the method get_from_code
26 27 28 29 |
# File 'lib/sal/format.rb', line 26 def Format.get_from_file( filename ) code = IO.binread(filename) return get_from_code( code ) end |
.get_from_line(line) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/sal/format.rb', line 31 def Format.get_from_line( line ) if(line.start_with? ".head") return Format::TEXT elsif(line.start_with? "Application Description" or line.start_with? "\t") return Format::INDENTED else return Format::NORMAL end end |