Class: Teepee::Commander

Direct Known Subclasses

ActionableCommander

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Teepee::CommanderMixins::ThinkingBicycleModels

#bookmarks_folder_id, #folder_id, #forum_id, #id_command_handler, #image, #keyword_id, #link, #link_id, #mailto, #note_id, #tag_id, #tb_href, #user

Methods included from Teepee::CommanderMixins::Mathematics

#%, #*, #**, #+, #-, #/, #acos, #acosh, #add_percentage, #asin, #asinh, #atan, #atanh, #ceiling, #cos, #cosh, #degrees2radians, #e, #ensure_numeric, #erf, #erfc, #floor, #gamma, #greater_than, #greater_than_or_equal, #hypot, #i, #ld, #ldexp, #less_than, #less_than_or_equal, #lgamma, #ln, #log, #log10, #mod, #non_numeric_error, #number_from_word, #numeric?, #percent_total, #pi, #radians2degrees, #round, #sin, #sinh, #sqrt, #subtract_percentage, #tan, #tanh, #to_numbers

Methods included from Teepee::CommanderMixins::Formatting

#b, #big, #br, #del, #enumerate, #enumerate_lowercase, #enumerate_numeric, #enumerate_roman_lowercase, #enumerate_roman_uppercase, #enumerate_uppercase, #h1, #h2, #h3, #h4, #h5, #h6, #html_tag, #it, #item, #itemize, #itemize_circle, #itemize_disc, #itemize_none, #itemize_square, #nbsp, #small, #span_operator, #sub, #sup, #table, #table_data, #table_header, #table_row, #tt, #u

Methods included from Teepee::CommanderMixins::Control

#case_operator, #comment, #cond_operator, #decrement, #define, #dotimes, #equal, #get_operator, #if_operator, #increment, #is_defined?, #not_equal, #prog1_operator, #progn_operator, #prognil, #undefine, #unless_operator, #when_operator

Methods included from Teepee::CommanderMixins::Boolean

#boolean_and, #boolean_nand, #boolean_nor, #boolean_not, #boolean_or, #boolean_xnor, #boolean_xor, #ensure_boolean, #false_constant, #false_constant?, #true_constant, #true_constant?

Constructor Details

#initialize(params) ⇒ Commander

Returns a new instance of Commander.



54
55
56
# File 'lib/teepee/commander.rb', line 54

def initialize params
  # We don't use the params in the base class, but might in derived classes.
end

Instance Attribute Details

#parserObject

Returns the value of attribute parser.



52
53
54
# File 'lib/teepee/commander.rb', line 52

def parser
  @parser
end

Instance Method Details

#backquoteObject



102
103
104
# File 'lib/teepee/commander.rb', line 102

def backquote
  "`"
end

#backslashObject



106
107
108
# File 'lib/teepee/commander.rb', line 106

def backslash
  "\\"
end

#command_error(message) ⇒ Object



64
65
66
# File 'lib/teepee/commander.rb', line 64

def command_error message
  %{<span style="color: red">[#{message}]</span>}
end

#command_not_yet_implemented(command) ⇒ Object



68
69
70
# File 'lib/teepee/commander.rb', line 68

def command_not_yet_implemented command
  command_error "The command #{command} is not yet implemented."
end

#dollarObject



110
111
112
# File 'lib/teepee/commander.rb', line 110

def dollar
  "$"
end

#left_braceObject



114
115
116
# File 'lib/teepee/commander.rb', line 114

def left_brace
  "{"
end

#left_bracketObject



118
119
120
# File 'lib/teepee/commander.rb', line 118

def left_bracket
  "["
end

#left_strip(expressions) ⇒ Object



76
77
78
79
80
81
# File 'lib/teepee/commander.rb', line 76

def left_strip expressions
  while expressions.first.kind_of? WhitespaceToken
    expressions.shift
  end
  expressions
end

#pipeObject



122
123
124
# File 'lib/teepee/commander.rb', line 122

def pipe
  "|"
end

#pipe?(expression) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/teepee/commander.rb', line 98

def pipe? expression
  expression.is_a? PipeToken
end

#right_braceObject



126
127
128
# File 'lib/teepee/commander.rb', line 126

def right_brace
  "}"
end

#right_bracketObject



130
131
132
# File 'lib/teepee/commander.rb', line 130

def right_bracket
  "]"
end

#right_strip(expressions) ⇒ Object



83
84
85
86
87
88
# File 'lib/teepee/commander.rb', line 83

def right_strip expressions
  while expressions.last.kind_of? WhitespaceToken
    expressions.pop
  end
  expressions
end

#spaceObject



138
139
140
# File 'lib/teepee/commander.rb', line 138

def space
  " "
end

#squiggleObject



134
135
136
# File 'lib/teepee/commander.rb', line 134

def squiggle
  "~"
end

#strip(expressions) ⇒ Object



90
91
92
# File 'lib/teepee/commander.rb', line 90

def strip expressions
  left_strip right_strip expressions
end

#valid_email_address?(email_address) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/teepee/commander.rb', line 94

def valid_email_address? email_address
  email_address =~ /\A[[:graph:]]+@[\w._-]+\z/
end

#valid_uri?(uri) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/teepee/commander.rb', line 58

def valid_uri? uri
  (!! (u = URI.parse(uri))) and not u.scheme.nil?
rescue URI::InvalidURIError
  false
end

#variable_not_defined_error(variable) ⇒ Object



72
73
74
# File 'lib/teepee/commander.rb', line 72

def variable_not_defined_error variable
  command_error "The variable \"#{variable}\" is not defined."
end