Class: Include
Overview
Base class for C header includes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#include_path ⇒ Object
readonly
Returns the value of attribute include_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#!~(pattern) ⇒ Object
Not matching operator for pattern matching on filename.
-
#==(other) ⇒ Object
(also: #eql?)
Equality operator -- for Include objects and strings.
-
#=~(pattern) ⇒ Object
Matching operator for pattern matching on filename.
-
#hash ⇒ Object
Hash method for use in sets and as hash keys.
-
#include ⇒ Object
Returns the configured entry to use in the include directive.
-
#initialize(statement, include_path: nil) ⇒ Include
constructor
Initialize an Include object from a C include statement or simple filepath.
-
#to_s ⇒ Object
Method specialized by subclasses.
- #to_str ⇒ Object
Constructor Details
#initialize(statement, include_path: nil) ⇒ Include
Initialize an Include object from a C include statement or simple filepath.
285 286 287 288 289 290 291 292 293 |
# File 'lib/ceedling/includes/includes.rb', line 285 def initialize(statement, include_path: nil) @filepath = clean(statement) raise ArgumentError, "Empty include statement" if @filepath.empty? @filename = File.basename(@filepath) @path = File.dirname(@filepath) @include_path = clean(include_path) if include_path end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
267 268 269 |
# File 'lib/ceedling/includes/includes.rb', line 267 def filename @filename end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
266 267 268 |
# File 'lib/ceedling/includes/includes.rb', line 266 def filepath @filepath end |
#include_path ⇒ Object (readonly)
Returns the value of attribute include_path.
269 270 271 |
# File 'lib/ceedling/includes/includes.rb', line 269 def include_path @include_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
268 269 270 |
# File 'lib/ceedling/includes/includes.rb', line 268 def path @path end |
Instance Method Details
#!~(pattern) ⇒ Object
Not matching operator for pattern matching on filename
337 338 339 |
# File 'lib/ceedling/includes/includes.rb', line 337 def !~(pattern) @filename !~ pattern end |
#==(other) ⇒ Object Also known as: eql?
Equality operator -- for Include objects and strings
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/ceedling/includes/includes.rb', line 308 def ==(other) case other when String include == other when UserInclude, MockInclude if self.is_a?(SystemInclude) false else include == other.include end when SystemInclude if self.is_a?(UserInclude) false else include == other.include end when Include include == other.include else false end end |
#=~(pattern) ⇒ Object
Matching operator for pattern matching on filename
332 333 334 |
# File 'lib/ceedling/includes/includes.rb', line 332 def =~(pattern) @filename =~ pattern end |
#hash ⇒ Object
Hash method for use in sets and as hash keys
342 343 344 |
# File 'lib/ceedling/includes/includes.rb', line 342 def hash() include.hash end |
#include ⇒ Object
Returns the configured entry to use in the include directive
350 351 352 353 |
# File 'lib/ceedling/includes/includes.rb', line 350 def include() return @include_path if @include_path @filename end |
#to_s ⇒ Object
Method specialized by subclasses
296 297 298 299 |
# File 'lib/ceedling/includes/includes.rb', line 296 def to_s() # Simple string representation of class contents with no additional formatting or #include decoration return @filename end |
#to_str ⇒ Object
301 302 303 304 305 |
# File 'lib/ceedling/includes/includes.rb', line 301 def to_str() # Coerce to string for implicit conversions (e.g., string interpolation, concatenation) # For instance, Rake#FileList needs this to treat Include objects as strings when extending with #pathmap return @filename end |