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

View file

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

View file

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