Class: Format
- Inherits:
-
Object
- Object
- Format
- Defined in:
- lib/format.rb
Overview
Allows for C-like source code to be formatted using several popular bracketing styles.
Class Method Summary collapse
-
.ALLMAN ⇒ Integer
Allman bracketing style.
-
.format(file, options = {}) ⇒ Object
Formats the input file according to the input options.
-
.JAVA ⇒ Integer
Java bracketing style.
- .SUN ⇒ Object
-
.UNIX ⇒ Integer
UNIX bracketing style.
-
.VERSION ⇒ String
Gives the current version of format.
- .WHITESMITH ⇒ Object
Class Method Details
.ALLMAN ⇒ Integer
Allman bracketing style
166 167 168 |
# File 'lib/format.rb', line 166 def self.ALLMAN 1 end |
.format(file, options = {}) ⇒ Object
Formats the input file according to the input options.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/format.rb', line 223 def self.format(file, ={}) indent = [:indentation] if indent == nil then indent = ' ' end output = nil case [:style] when self.ALLMAN output = File.new(file + '.allman', 'w+') self.allman(file, output, indent) when self.UNIX output = File.new(file + '.unix', 'w+') self.unix(file, output, indent) when self.JAVA output = File.new(file + '.sun', 'w+') self.java(file, output, indent) else puts 'Defaulting to Java style formatting...' output = File.new(file + '.sun', 'w+') self.java(file, output, indent) end output.close end |
.JAVA ⇒ Integer
Java bracketing style
186 187 188 |
# File 'lib/format.rb', line 186 def self.JAVA 3 end |
.SUN ⇒ Object
193 194 195 |
# File 'lib/format.rb', line 193 def self.SUN self.JAVA end |
.UNIX ⇒ Integer
UNIX bracketing style
176 177 178 |
# File 'lib/format.rb', line 176 def self.UNIX 2 end |
.VERSION ⇒ String
Gives the current version of format.
206 207 208 209 210 211 212 |
# File 'lib/format.rb', line 206 def self.VERSION if @@version == nil then file = File.dirname(__FILE__) + '/../VERSION' @@version = File.exists?(file) ? File.read(file) : '' end @@version end |
.WHITESMITH ⇒ Object
197 198 199 |
# File 'lib/format.rb', line 197 def self.WHITESMITH 4 end |