Add Type annotations and remove Symbol usage

Remove Ruby's *symbols everywhere* approach to define getter/setters
or properties. Crystal's parser and macros do not require symbols
for these options.

Also add type annotations to some elements aiming to improve quality
of the documentation generated (more accurate expected types).
This commit is contained in:
Luis Lavena 2016-03-15 20:28:14 -03:00
parent 9e3316c93f
commit 303a70dbfe
3 changed files with 11 additions and 11 deletions

View file

@ -27,10 +27,10 @@ module Radix
# # => [3, 2, 1]
# ```
class Node
getter :key
getter? :placeholder
property! :payload
property :children
getter key : String
getter? placeholder : Bool
property! payload
property children : Array(Node)
# Returns the priority of the Node based on it's *key*
#
@ -54,7 +54,7 @@ module Radix
# Node.new(":query").priority
# # => 1
# ```
getter :priority
getter priority : Int32
# Instantiate a Node
#

View file

@ -13,8 +13,8 @@ module Radix
# A Result is also used recursively by `Tree#find` when collecting extra
# information like *params*.
class Result
getter :params
getter! :payload
getter params
getter! payload
# :nodoc:
def initialize
@ -35,7 +35,7 @@ module Radix
# result.found?
# # => true
# ```
def found?
def found? : Bool
payload? ? true : false
end
@ -60,7 +60,7 @@ module Radix
# result.key
# # => ""
# ```
def key
def key : String
return @key if @key
key = String.build { |io|

View file

@ -30,7 +30,7 @@ module Radix
# Returns the root `Node` element of the Tree.
#
# On a new tree instance, this will be a placeholder.
getter :root
getter root : Node
def initialize
@root = Node.new("", placeholder: true)
@ -397,7 +397,7 @@ module Radix
end
# :nodoc:
private def deprecation(message)
private def deprecation(message : String)
STDERR.puts message
STDERR.flush
end