Skip to content

Instantly share code, notes, and snippets.

@jadehopepunk
Created January 13, 2015 02:07
Show Gist options
  • Save jadehopepunk/21e00c09f7a9342f8a91 to your computer and use it in GitHub Desktop.
Save jadehopepunk/21e00c09f7a9342f8a91 to your computer and use it in GitHub Desktop.
class IndentManager
def initialize
@indents = []
@parse_complete = false
end
def register_indent(indent)
@indents << indent
end
def parse_complete!
@parse_complete = true
end
def normalize(value)
value * normalization_factor
end
private
def normalization_factor
raise RuntimeError.new("you can't normalize until you have finished parsing") unless @parse_complete
@normalization_factor ||= compute_normalization_factor
end
def compute_normalization_factor
# loop through @indents and figure out normalization
end
end
class Indent
def initialize(value, indent_manager)
@value = value
@indent_manager = indent_manager
@indent_manager.register_indent(self)
end
def unnormalised
@value
end
def normalized
@indent_manager.normalize(value)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment