Parses a range in Ruby syntax and returns a Range instance.

@param string $range

@return self
506027
public static function parse($range)
    {
        $matches = array();

        if (preg_match(self::REGEX, $range, $matches) !== 1) {
            throw new InvalidArgumentException(sprintf('Provided range "%s" does not match Ruby syntax.', $range));
        }

        return new self($matches[1] + 0, $matches[3] + 0, $matches[2] === '.');
    }
382677
public function filterRange($range)
    {
        if (is_int($range)) {
            $level = $range;
            $depth = 0;
        } else {
            reset($range);
            $level = key($range);
            $depth = current($range);
        }

        if (1 === $level) {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.'  ]')->item(0);
        } else {
            $nodeList = $this->xp->query('/descendant-or-self::*[ name() = "ul" and count( ancestor-or-self::ul ) >= '.$level.' and ( descendant-or-self::*[ contains(@class, "open") or contains(@class, "active") ] or ancestor-or-self::*[ contains(@class, "open")  or contains(@class, "active") ] ) ]')->item(0);
        }

        if (!$nodeList) {
            return false;
        }

        if (false === $depth) {
            return $nodeList;
        }

        $depthNodelist = $this->xp->query('./descendant::*[ name() = "ul" and count( ancestor-or-self::ul ) > '.($level + $depth).' ]', $nodeList);

        foreach ($depthNodelist as $node) {
            $node->parentNode->removeChild($node);
        }

        if ($nodeList) {
            return $nodeList;
        } else {
            return false;
        }
    }
930646
public function containsRange(RangeInterface $range)
    {
        $result = false;
        if ($range->getAddressType() === $this->getAddressType()) {
            $myStart = $this->getComparableStartString();
            $itsStart = $range->getComparableStartString();
            if ($itsStart >= $myStart) {
                $myEnd = $this->getComparableEndString();
                $itsEnd = $range->getComparableEndString();
                if ($itsEnd <= $myEnd) {
                    $result = true;
                }
            }
        }

        return $result;
    }
151184
public function setRange($range)
    {
        $allowed_values = array('station', 'region', 'solarsystem', '1', '2', '3', '4', '5', '10', '20', '30', '40');
        if ((!in_array($range, $allowed_values))) {
            throw new \InvalidArgumentException("Invalid value for 'range', must be one of 'station', 'region', 'solarsystem', '1', '2', '3', '4', '5', '10', '20', '30', '40'");
        }
        $this->container['range'] = $range;

        return $this;
    }
591212
public function abuts(DateTimeRange $range)
	{
		return !$this->overlaps($range) && $this->gap($range)->isEmpty();
	}
22413
public static function sort(array &$range) {
        usort($range, function(TimePoint $a, TimePoint $b) {
            return $a->compare($b);
        });
        return $range;
    }
1155801
public function get($table, $hash, $range = null, Context\Get $context = null)
    {
        if (null !== $this->logger) {
            $this->log('Get on table '.$table);
        }

        // Primary key
        $hash = new Attribute($hash);

        $parameters = array(
            'TableName' => $table,
            'Key'       => array(
                'HashKeyElement' => $hash->getForDynamoDB()
            )
        );

        // Range key
        if (null !== $range) {
            $range = new Attribute($range);
            $parameters['Key']['RangeKeyElement'] = $range->getForDynamoDB();
        }

        if (null !== $context) {
            $parameters += $context->getForDynamoDB();
        }

        if (null !== $this->logger) {
            $this->log('Get request paramaters : '.print_r($parameters, true), Logger::DEBUG);
        }

        $response = $this->connector->getItem($parameters);

        if (null !== $this->logger) {
            $this->log('Get request response : '.print_r($response, true), Logger::DEBUG);
        }

        $this->addConsumedReadUnits($table, floatval($response['ConsumedCapacityUnits']));

        if (isset($response['Item'])) {
            $item = new Item($table);
            $item->populateFromDynamoDB($response['Item']);
            return $item;
        } else {
            if (null !== $this->logger) {
                $this->log('Didn\'t find item');
            }
            return null;
        }
    }
823108
public static function fromRange(LineRangeInterface $range, $bufferLength)
    {
        return new self(sprintf(
            'Range %d-%d goes beyond buffer with %d lines.',
            $range->getStart()->getNumber(),
            $range->getEnd()->getNumber(),
            $bufferLength
        ));
    }
490375
public function equals(DateTimeRange $range)
	{
		return $this->start->equals($range->start) && $this->end->equals($range->end) && $this->interval->equals($range->interval);
	}
1110726
private static function parseRange($range, $partSize)
    {
        // Strip away the prefix and suffix.
        if (strpos($range, 'bytes') !== false) {
            $range = substr($range, 6, -2);
        }

        // Split that range into it's parts.
        list($firstByte, $lastByte) = explode('-', $range);

        // Calculate and return range index and range size
        return [
            intval($firstByte / $partSize) + 1,
            $lastByte - $firstByte + 1,
        ];
    }
909763
public function range($from, $to, $condition = true) {
		$range = new Range($this, !$condition);
		$range->setFrom($from);
		$range->setTo($to);
		return $range;
	}
206264
def range_parse(s):
    
    chr, se = s.split(":")
    start, end = se.split("-")
    start, end = int(start), int(end)
    if start > end:
        start, end = end, start

    return Range(chr, start, end, 0, 0)
34892
private static function range(ResponseInterface $response, string $range): ResponseInterface
    {
        $response = $response->withHeader('Accept-Ranges', 'bytes');

        if (empty($range) || !($range = self::parseRangeHeader($range))) {
            return $response;
        }

        list($first, $last) = $range;
        $size = $response->getBody()->getSize();

        if ($last === null) {
            $last = $size - 1;
        }

        return $response
            ->withStatus(206)
            ->withHeader('Content-Length', (string) ($last - $first + 1))
            ->withHeader('Content-Range', sprintf('bytes %d-%d/%d', $first, $last, $size));
    }
311061
public function setRange($range)
    {
        $allowedValues = $this->getRangeAllowableValues();
        if (!in_array($range, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'range', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['range'] = $range;

        return $this;
    }
715946
private static function cast(DateTimeRange $range)
	{
		$start = new Date($range->start());
		$end   = new Date($range->end());

		return new DateRange($start, $end);
	}
84474
public function getPageRange($range = 4)
    {
        $from = max(1, $this->getPage() - $range);
        $to = min($this->getPageCount(), $this->getPage() + $range);

        return range($from, $to);
    }
878147
private List<String> extractRanges(String range) {
		List<String> ranges;
		String[] rangeSpl = range.split(",");

		// Recent versions of scop always specify a chain, so no processing is needed
		if(scopVersion.compareTo("1.73") < 0 ) {
			for(int i=0; i<rangeSpl.length;i++) {
				String subRange = rangeSpl[i];

				// Allow single-chains, as well as the '-' special case
				if(subRange.length()<2) {
					continue;
				}

				// Allow explicit chain syntax
				if(subRange.charAt(1) != ':') {
					// Early versions sometimes skip the chain identifier for single-chain domains
					// Indicate this with a chain "_"
					rangeSpl[i] = "_:"+subRange;
				}
			}
		}
		ranges = Arrays.asList(rangeSpl);
		return ranges;
	}