Class: LightningCSS::Result
- Inherits:
-
Object
- Object
- LightningCSS::Result
- Defined in:
- lib/lightningcss/result.rb,
sig/lightningcss/result.rbs
Overview
What a transform produced.
exports is only filled in when the stylesheet was compiled as a CSS module, and maps every
name as it was written to the name it was compiled to. A transform that was not asked for a
CSS module has none, and neither does a style attribute, which has no names to compile.
warnings holds what Lightning CSS understood well enough to keep but not well enough to act
on, which is everything it would otherwise have dropped without saying so.
Instance Attribute Summary collapse
- #code ⇒ String readonly
- #exports ⇒ Hash[String, String]? readonly
- #warnings ⇒ Array[String] readonly
Class Method Summary collapse
-
.from_json(payload) ⇒ LightningCSS::Result
: (String) -> LightningCSS::Result.
Instance Method Summary collapse
-
#initialize(code:, warnings:, exports: nil) ⇒ Result
constructor
: (code: String, warnings: Array, ?exports: Hash[String, String]?) -> void.
-
#inspect ⇒ String
: () -> String.
-
#to_s ⇒ String
: () -> String.
-
#warnings? ⇒ Boolean
: () -> bool.
Constructor Details
#initialize(code:, warnings:, exports: nil) ⇒ Result
: (code: String, warnings: Array, ?exports: Hash[String, String]?) -> void
30 31 32 33 34 35 36 |
# File 'lib/lightningcss/result.rb', line 30 def initialize(code:, warnings:, exports: nil) @code = code @exports = exports @warnings = warnings.freeze freeze end |
Instance Attribute Details
#code ⇒ String (readonly)
14 15 16 |
# File 'lib/lightningcss/result.rb', line 14 def code @code end |
#exports ⇒ Hash[String, String]? (readonly)
15 16 17 |
# File 'lib/lightningcss/result.rb', line 15 def exports @exports end |
#warnings ⇒ Array[String] (readonly)
16 17 18 |
# File 'lib/lightningcss/result.rb', line 16 def warnings @warnings end |
Class Method Details
.from_json(payload) ⇒ LightningCSS::Result
: (String) -> LightningCSS::Result
19 20 21 22 23 24 25 26 27 |
# File 'lib/lightningcss/result.rb', line 19 def self.from_json(payload) parsed = JSON.parse(payload) new( code: parsed.fetch("code"), exports: parsed["exports"], warnings: parsed.fetch("warnings") ) end |
Instance Method Details
#inspect ⇒ String
: () -> String
49 50 51 52 53 54 55 |
# File 'lib/lightningcss/result.rb', line 49 def inspect parts = ["code=#{code.inspect}"] parts << "exports=#{exports.inspect}" if exports parts << "warnings=#{warnings.inspect}" if warnings? "#<#{self.class.name} #{parts.join(" ")}>" end |
#to_s ⇒ String
: () -> String
44 45 46 |
# File 'lib/lightningcss/result.rb', line 44 def to_s code end |
#warnings? ⇒ Boolean
: () -> bool
39 40 41 |
# File 'lib/lightningcss/result.rb', line 39 def warnings? !warnings.empty? end |