Class: Mayu::Resources::Types::SVG
- Extended by:
- T::Sig
- Defined in:
- lib/mayu/resources/types/svg.rb
Constant Summary collapse
- MarshalFormat =
T.type_alias { [String, String] }
Instance Method Summary collapse
- #assets ⇒ Object
-
#initialize(resource) ⇒ SVG
constructor
A new instance of SVG.
- #marshal_dump ⇒ Object
- #marshal_load(args) ⇒ Object
- #src ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(resource) ⇒ SVG
Returns a new instance of SVG.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mayu/resources/types/svg.rb', line 13 def initialize(resource) @resource = resource source = resource.read(encoding: "utf-8") content_hash = Base64.urlsafe_encode64(Digest::SHA256.digest(source)) @filename = T.let("#{content_hash}.svg", String) @source = T.let(source, String) end |
Instance Method Details
#assets ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/mayu/resources/types/svg.rb', line 25 def assets [ Asset.new( @filename, Generators::WriteFile.new(contents: @source, compress: true) ) ] end |
#marshal_dump ⇒ Object
43 44 45 |
# File 'lib/mayu/resources/types/svg.rb', line 43 def marshal_dump [@source, @filename] end |
#marshal_load(args) ⇒ Object
48 49 50 |
# File 'lib/mayu/resources/types/svg.rb', line 48 def marshal_load(args) @source, @filename = args end |
#src ⇒ Object
38 |
# File 'lib/mayu/resources/types/svg.rb', line 38 def src = "/__mayu/static/#{@filename}" |
#to_s ⇒ Object
35 |
# File 'lib/mayu/resources/types/svg.rb', line 35 def to_s = src |