-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the messages, refactor to schemas and messages
- Loading branch information
1 parent
77f051d
commit d85e09a
Showing
4 changed files
with
50 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module S2 | ||
module Schemas | ||
|
||
# The fill level range for which this FRBC.LeakageBehaviourElement applies. The start of | ||
# the range must be less than the end of the range. | ||
class NumberRange < Dry::Struct | ||
|
||
# Number that defines the end of the range | ||
attribute :end_of_range, S2::Messages::Types::Double | ||
|
||
# Number that defines the start of the range | ||
attribute :start_of_range, S2::Messages::Types::Double | ||
|
||
def self.from_dynamic!(d) | ||
d = S2::Messages::Types::Hash[d] | ||
new( | ||
end_of_range: d.fetch("end_of_range"), | ||
start_of_range: d.fetch("start_of_range"), | ||
) | ||
end | ||
|
||
def self.from_json!(json) | ||
from_dynamic!(JSON.parse(json)) | ||
end | ||
|
||
def to_dynamic | ||
{ | ||
"end_of_range" => end_of_range, | ||
"start_of_range" => start_of_range, | ||
} | ||
end | ||
|
||
def to_json(options = nil) | ||
JSON.generate(to_dynamic, options) | ||
end | ||
end | ||
end | ||
end |