Skip to content

Instantly share code, notes, and snippets.

@notrab
Created April 10, 2014 09:50
Show Gist options
  • Save notrab/10363010 to your computer and use it in GitHub Desktop.
Save notrab/10363010 to your computer and use it in GitHub Desktop.
class DoorCore
def initialize(input_width)
@min_height = 2120.to_f
@max_height = 2455.to_f
@min_width = 915.to_f
@max_width = 1080.to_f
@input_width = input_width
end
def predicted_max_height
@result = @max_height - (@input_width - @min_width) * (@max_height - @min_height) / (@max_width - @min_width)
@result.floor
end
end
puts "\n---------------------------\nWhat is your desired width?\n---------------------------\n"
desired_width = gets.to_f
app = DoorCore.new(desired_width)
output = app.predicted_max_height
puts "\nResult: #{output}"
@notrab
Copy link
Author

notrab commented Apr 10, 2014

and for calculated width

class DoorCore
  def initialize(input_width)
    @min_height   = 2120.to_f
    @max_height   = 2455.to_f
    @min_width    = 915.to_f
    @max_width    = 1080.to_f
    @input_width  = input_width
  end

  def predicted_max_width
    @result = @max_width - (@input_height - @min_height) * (@max_width - @min_width) / (@max_height - @min_height)
    @result.floor
  end
end

puts "\n---------------------------\nWhat is your desired width?\n---------------------------\n"
desired_width = gets.to_f

app = DoorCore.new(desired_width)
output = app.predicted_max_height

puts "\nResult: #{output}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment