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.
-
#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, use_path: false) ⇒ 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, use_path: false) ⇒ Include
Initialize an Include object from a C include statement or simple filepath.
231 232 233 234 235 236 237 238 239 |
# File 'lib/ceedling/includes/includes.rb', line 231 def initialize(statement, use_path: false) @filepath = clean(statement) raise ArgumentError, "Empty include statement" if @filepath.empty? @filename = File.basename(@filepath) @path = File.dirname(@filepath) @use_path = use_path end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
217 218 219 |
# File 'lib/ceedling/includes/includes.rb', line 217 def filename @filename end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
216 217 218 |
# File 'lib/ceedling/includes/includes.rb', line 216 def filepath @filepath end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
218 219 220 |
# File 'lib/ceedling/includes/includes.rb', line 218 def path @path end |
Instance Method Details
#!~(pattern) ⇒ Object
Not matching operator for pattern matching on filename
283 284 285 |
# File 'lib/ceedling/includes/includes.rb', line 283 def !~(pattern) @filename !~ pattern end |
#==(other) ⇒ Object Also known as: eql?
Equality operator -- for Include objects and strings
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/ceedling/includes/includes.rb', line 254 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
278 279 280 |
# File 'lib/ceedling/includes/includes.rb', line 278 def =~(pattern) @filename =~ pattern end |
#hash ⇒ Object
Hash method for use in sets and as hash keys
288 289 290 |
# File 'lib/ceedling/includes/includes.rb', line 288 def hash() include.hash end |
#include ⇒ Object
Returns the configured entry to use in the include directive
296 297 298 |
# File 'lib/ceedling/includes/includes.rb', line 296 def include() @use_path ? @filepath : @filename end |
#to_s ⇒ Object
Method specialized by subclasses
242 243 244 245 |
# File 'lib/ceedling/includes/includes.rb', line 242 def to_s() # Simple string representation of class contents with no additional formatting or #include decoration return @filename end |
#to_str ⇒ Object
247 248 249 250 251 |
# File 'lib/ceedling/includes/includes.rb', line 247 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 |