Class: Rubyang::Model::ArgStmt
Direct Known Subclasses
Anyxml, Argument, Augment, Base, BelongsTo, Bit, Case, Choice, Config, ConformanceRelated, Contact, Container, Default, Description, Deviate, Deviation, Enum, ErrorAppTag, ErrorMessage, Extension, Feature, FractionDigits, Grouping, Identity, Identityref, IfFeature, Import, Include, Key, Leaf, LeafList, Leafref, Length, List, Mandatory, MaxElements, MinElements, Module, Must, Namespace, Notification, OrderedBy, Organization, Path, Pattern, Position, Prefix, Presence, Range, Reference, Refine, RequireInstance, Revision, RevisionDate, Rpc, Status, Submodule, Type, Typedef, Union, Unique, Units, Unknown, Uses, Value, When, YangVersion, YinElement
Instance Method Summary
collapse
Methods inherited from BaseStmt
#has_substmt?, #not_schema_node_substmts, #schema_node_substmts, #substatements, #substmt, #substmts, #to_yang, #without_not_schema_node_substmts
Constructor Details
#initialize(arg, substmts = []) ⇒ ArgStmt
Returns a new instance of ArgStmt.
146
147
148
149
150
151
152
|
# File 'lib/rubyang/model.rb', line 146
def initialize arg, substmts=[]
super substmts
@arg = arg
unless valid_arg? arg
raise ArgumentError, "Invalid Argument: '#{arg}'"
end
end
|
Instance Method Details
#arg ⇒ Object
161
162
163
|
# File 'lib/rubyang/model.rb', line 161
def arg
@arg
end
|
#arg_regexp ⇒ Object
164
165
166
|
# File 'lib/rubyang/model.rb', line 164
def arg_regexp
'(?:.*)'
end
|
#to_s(parent = true) ⇒ Object
153
154
155
156
157
158
159
160
|
# File 'lib/rubyang/model.rb', line 153
def to_s parent=true
head, vars, tail = "#<#{self.class.to_s}:0x#{(self.object_id << 1).to_s(16).rjust(14,'0')} ", Array.new, ">"
if parent
vars.push "@arg=#{@arg.to_s}"
vars.push "@substmts=#{@substmts.map{|s| s.to_s(false)}}"
end
head + vars.join(', ') + tail
end
|
#valid_arg?(arg) ⇒ Boolean
167
168
169
170
|
# File 'lib/rubyang/model.rb', line 167
def valid_arg? arg
re = Regexp.new( "^#{arg_regexp}$" )
re === arg
end
|