Class: Mayu::Resources::Asset
- Inherits:
-
Object
- Object
- Mayu::Resources::Asset
- Extended by:
- T::Sig
- Defined in:
- lib/mayu/resources/asset.rb
Defined Under Namespace
Classes: Status
Constant Summary collapse
- MarshalFormat =
T.type_alias { [String] }
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #done? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(filename, generator) ⇒ Asset
constructor
A new instance of Asset.
- #marshal_dump ⇒ Object
- #marshal_load(args) ⇒ Object
- #pending? ⇒ Boolean
- #process(asset_dir) ⇒ Object
- #processing? ⇒ Boolean
Constructor Details
#initialize(filename, generator) ⇒ Asset
Returns a new instance of Asset.
30 31 32 33 34 |
# File 'lib/mayu/resources/asset.rb', line 30 def initialize(filename, generator) @filename = filename @generator = generator @status = T.let(Status::Pending, Status) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
23 24 25 |
# File 'lib/mayu/resources/asset.rb', line 23 def filename @filename end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
27 28 29 |
# File 'lib/mayu/resources/asset.rb', line 27 def generator @generator end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
25 26 27 |
# File 'lib/mayu/resources/asset.rb', line 25 def status @status end |
Instance Method Details
#done? ⇒ Boolean
41 |
# File 'lib/mayu/resources/asset.rb', line 41 def done? = @status == Status::Done |
#failed? ⇒ Boolean
43 |
# File 'lib/mayu/resources/asset.rb', line 43 def failed? = @status == Status::Failed |
#marshal_dump ⇒ Object
61 62 63 |
# File 'lib/mayu/resources/asset.rb', line 61 def marshal_dump [@filename] end |
#marshal_load(args) ⇒ Object
66 67 68 |
# File 'lib/mayu/resources/asset.rb', line 66 def marshal_load(args) @filename = args.first end |
#pending? ⇒ Boolean
37 |
# File 'lib/mayu/resources/asset.rb', line 37 def pending? = @status == Status::Pending |
#process(asset_dir) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mayu/resources/asset.rb', line 46 def process(asset_dir) return false unless pending? @status = Status::Processing @generator.process(File.join(asset_dir, filename)) rescue StandardError @status = Status::Failed raise else @status = Status::Done true end |
#processing? ⇒ Boolean
39 |
# File 'lib/mayu/resources/asset.rb', line 39 def processing? = @status == Status::Processing |