lib/ferver/file_id_request.rb in ferver-1.1.0 vs lib/ferver/file_id_request.rb in ferver-1.2.0

- old
+ new

@@ -1,28 +1,37 @@ module Ferver - class FileIdRequest + class FileIdRequest + attr_reader :value - attr_reader :value + def initialize(value = nil) + @is_valid = false - def initialize(value = nil) - @is_valid = false + self.value = value + end - self.value = value - end + def value=(value) + id = parse_value(value) - def value=(value) - id = Integer(value) rescue nil + if id.nil? + @is_valid = false + else + @value = id + @is_valid = true + end + end - if id.nil? - @is_valid = false - else - @value = id - @is_valid = true - end - end + def valid? + @is_valid + end - def valid? - @is_valid - end + private + + def parse_value(value) + begin + Integer(value) + rescue + nil + end end -end \ No newline at end of file + end +end