Class: Lutaml::Lml::Source
- Inherits:
-
Object
- Object
- Lutaml::Lml::Source
- Defined in:
- lib/lutaml/lml/source.rb
Overview
Normalizes pipeline input (String, StringIO, File, Tempfile) behind one interface: full text, filesystem path (or nil), and the directory imports/includes resolve against.
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Class Method Summary collapse
Instance Method Summary collapse
- #base_dir ⇒ Object
-
#initialize(input) ⇒ Source
constructor
A new instance of Source.
-
#path ⇒ Object
Filesystem path, or nil for anonymous input (String/StringIO).
- #read ⇒ Object
Constructor Details
#initialize(input) ⇒ Source
Returns a new instance of Source.
17 18 19 |
# File 'lib/lutaml/lml/source.rb', line 17 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
11 12 13 |
# File 'lib/lutaml/lml/source.rb', line 11 def input @input end |
Class Method Details
.wrap(input) ⇒ Object
13 14 15 |
# File 'lib/lutaml/lml/source.rb', line 13 def self.wrap(input) input.is_a?(Source) ? input : new(input) end |
Instance Method Details
#base_dir ⇒ Object
34 35 36 |
# File 'lib/lutaml/lml/source.rb', line 34 def base_dir path ? File.dirname(path) : Dir.pwd end |
#path ⇒ Object
Filesystem path, or nil for anonymous input (String/StringIO).
29 30 31 32 |
# File 'lib/lutaml/lml/source.rb', line 29 def path io = unwrapped io.is_a?(File) ? io.path : nil end |
#read ⇒ Object
21 22 23 24 25 26 |
# File 'lib/lutaml/lml/source.rb', line 21 def read return @input if @input.is_a?(String) @input.rewind @input.read end |