IfOp
represents a ternary clause.
predicate ? truthy : falsyAttributes
Node
the expression to be executed if the predicate is falsy
Node
the expression to be checked
Node
the expression to be executed if the predicate is truthy
def initialize(predicate:, truthy:, falsy:, location:) @predicate = predicate @truthy = truthy @falsy = falsy @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(IfOp) && predicate === other.predicate && truthy === other.truthy && falsy === other.falsy endSource
def accept(visitor) visitor.visit_if_op(self) endSource
def child_nodes [predicate, truthy, falsy] endSource
def copy(predicate: nil, truthy: nil, falsy: nil, location: nil) node = IfOp.new( predicate: predicate || self.predicate, truthy: truthy || self.truthy, falsy: falsy || self.falsy, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node endSource
def deconstruct_keys(_keys) { predicate: predicate, truthy: truthy, falsy: falsy, location: location, comments: comments } endSource
def format(q) force_flat = [ AliasNode, Assign, Break, Command, CommandCall, Heredoc, IfNode, IfOp, Lambda, MAssign, Next, OpAssign, RescueMod, ReturnNode, Super, Undef, UnlessNode, VoidStmt, YieldNode, ZSuper ] if q.parent.is_a?(Paren) || force_flat.include?(truthy.class) || force_flat.include?(falsy.class) q.group { format_flat(q) } return end q.group { q.if_break { format_break(q) }.if_flat { format_flat(q) } } end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4