Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions lib/fbe/pmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def initialize(value, default, type, memo)
define_method(:areas) do
xml.xpath('/pmp/area/@name').map(&:value)
end
others do |*args1|
others do |*args1| # rubocop:disable Metrics/BlockLength
area = args1.first.to_s
node = xml.at_xpath("/pmp/area[@name='#{area}']")
if node.nil?
Expand Down Expand Up @@ -101,20 +101,36 @@ def initialize(value, default, type, memo)
type = prop.at_xpath('type').text
memo = prop.at_xpath('memo').text
default =
case type
when 'int' then Integer(default, 10)
when 'float' then Float(default)
when 'bool' then default == 'true'
else default
begin
case type
when 'int' then Integer(default, 10)
when 'float' then Float(default)
when 'bool' then default == 'true'
else default
end
rescue ArgumentError, TypeError => e
raise(
Fbe::Error,
"Invalid default value '#{default}' for PMP property " \
"'#{param}' in area '#{area}': #{e.message}"
)
end
end
result ||= default
result =
case type
when 'int' then Integer(Float(result).truncate)
when 'float' then Float(result)
when 'bool' then result.to_s == 'true'
else result
begin
case type
when 'int' then Integer(Float(result).truncate)
when 'float' then Float(result)
when 'bool' then result.to_s == 'true'
else result
end
rescue ArgumentError, TypeError => e
raise(
Fbe::Error,
"Invalid value '#{result}' for PMP property " \
"'#{param}' in area '#{area}': #{e.message}"
)
end
pmpv.new(result, default, type, memo)
end
Expand Down
Loading